Prosecutors continue to make unforced errors in the trial of Sergey Aleynikov, the former Goldman Sachs programmer who is being tried for the second time on charges he stole some of the source code to Goldman’s high-frequency trading program.

A New York Supreme Court justice ruled on Tuesday that prosecutors for the Manhattan district attorney, Cyrus Vance Jr., could not call an expert witness to testify because the prosecution team had told Mr. Aleynikov’s lawyer earlier that it had no plans to call any expert witnesses.

“I can’t remember the last time I precluded an expert,” said Justice Daniel P. Conviser said in a ruling from the bench. “I am very disappointed I have to do this thing.”

But the judge said he had to take the unusual step of precluding Spencer Lynch, a computer forensics specialist, from testifying because it might prejudice Mr. Aleynikov’s ability to receive a fair trial. The judge, noting that the trial has been underway for several days, said Mr. Aleynikov’s lawyer, Kevin Marino, was not given adequate time to prepare for cross-examination or arrange to have his own expert witness take the stand to rebut Mr. Lynch’s testimony.