Justice Minister Cathy Jamieson has told the Scottish Prison Service (SPS) to review its procedures after a woman mistakenly spent a week in jail.
Cathy Jamieson has faced renewed calls for her resignation
The 39-year-old, who has a rare blood disorder, was returned to Cornton Vale in error after appearing at Glasgow District Court on shoplifting charges.
The SPS accepted responsibility for the mistake and launched an inquiry.
But the Scottish National Party renewed calls for Ms Jamieson to quit over what it described as "repeated scandals".
Justice spokeswoman Nicola Sturgeon said: "Prisoners are being released who have been found guilty, the Scottish Executive made a hash of the slopping out appeal, and now we have a dying woman found innocent by the court but imprisoned for a week.
"The system is in chaos, taxpayers are facing yet another bill for compensation and yet Cathy Jamieson is grimly hanging on to her ministerial salary.
"This is her third strike; Cathy must be out."
Another, similar case has emerged in which a man had served his sentence and should have been released from Barlinnie Prison in Glasgow last December.
Instead, he was held for three days before the Scottish Prison Service noticed the error. The man is now seeking compensation.
Ms Jamieson has already pledged to stay in her job and complete reforms of the justice system.
The man was held for three extra days in Barlinnie
Referring to the Cornton Vale error, an executive spokesman said: "The justice minister is concerned that such a mistake can have been made at all, but especially that the woman appears to have remained in prison for a week before the error was discovered.
"Clearly the investigation into this specific situation must look at how the woman was returned to Cornton Vale in the first place.
"However, the minister has asked the SPS to review their procedures for checking and accepting prisoners from the courts and, if necessary, take urgent steps to tighten these procedures."
The woman's lawyer, Grazia Robertson, said she may seek compensation.
"I have never come across a case like this before, where someone has been detained in error for this length of time," she said.
"We have advised her to seek legal advice and I would have thought that there would be compensation forthcoming."
An SPS spokesman said the woman had been remanded in custody on 4 May on a shoplifting charge, then returned to court two days later on a second charge.
Her not guilty plea to the first charge was accepted and she was given bail on the second.
However, instead of walking free she was sent back to prison and the error was only spotted when she returned to court the following week.
The spokesman said: "If an individual has been retained in error in one our establishments, I suppose the ultimate responsibility is ours.
"An inquiry is under way to find out if there was some paperwork error.
"It's not clear either why the woman did not mention she'd been freed."
The spokesman said the investigation would look at the role of court officials and prison staff, as well as guards employed by private security firm Reliance.
The company has been dogged by mistaken releases since taking up the contract for escorting prisoners.
Last week its managing director Tom Riall told a Holyrood committee that the firm was to some extent responsible for six of the 17 escapes which have taken place since it took over the contract to escort prisoners in April.
Ms Jamieson has faced calls for her resignation over the mistaken releases and the executive's failure to lodge an appeal in time against a ruling which awarded compensation to a prisoner for having to slop out.
The executive was last week granted more time to appeal against the decision.