Prison bosses were told to apologise to an inmate who was caught with drugs in his cell, after an inquiry by the Scottish Public Services Ombudsman.
The prisoner was found with methadone, a heroin substitute, at HMP Shotts.
However, the prisoner, named as Mr C, complained that Scottish Prison Service (SPS) staff had "adapted" the policy on searching and testing for drugs.
His complaint was taken up by the ombudsman who found in the prisoner's favour.
The ombudsman ruled that the SPS should put a policy in place for staff to follow when testing substances, take steps to make prisoners aware, remind staff to record search timings and "issue an apology" to the inmate.
The report into the investigation gave the SPS until 19 March to meet the recommendations and the apology was to be given by 2 February.
The complaint was raised in March 2010 after a search of the cell.
Staff said methadone was found in a cup after it was tested with a dip, similar to those used to test urine.
The prisoner was charged with a breach of discipline shortly after in the jail's orderly room.
The report stated that the charge was sound but identified "failings" in the way the test was carried out.
The report continued: "I would point out that it is not my office's role to question the grounds for placing Mr C on report nor is it my role to look at the decision reached in the orderly room.
"My role is restricted to considering the process that was applied, and followed, by the prison leading up to their decision to charge Mr C."