The National Security Agency announced it has been deleting hundreds of millions of phone calls and text messages it has collected since 2015 that they should never have had in the first place.

The Chicago Tribune reports that the number is close to 685 million.

The NSA’s bulk collection of call records was initially curtailed by Congress after former NSA contractor Edward Snowden leaked documents revealing extensive government surveillance. The law, enacted in June 2015, said that going forward, the data would be retained by telecommunications companies, not the NSA, but that the intelligence agency could query the massive database. Now the NSA is deleting all the information it collected from the queries. The agency released a statement late Thursday saying it started deleting the records in May after NSA analysts noted “technical irregularities in some data received from telecommunication service providers.” It also said the irregularities resulted in the NSA obtaining some call details it was not authorized to receive. That points to a failure of the program, according to David Kris, a former top national security official at the Justice Department. “They said they have to purge three years’ worth of data going back to 2015, and that the data they did collect during that time — which they are now purging — was not reliable and was infected with some kind of technical error,” said Kris, founder of Culper Partners, a consulting firm in Seattle. “So whatever insights they were hoping to get over the past three years from this program of collection … is all worthless. Because of that, they are throwing all the data away and basically starting over.”

So who’s at fault? The NSA refuses to say, but Senator Ron Wyden (D-Ore.), who has made shielding Americans’ data from the NSA his prime focus, blames the telecom companies:

“This incident shows these companies acted with unacceptable carelessness, and failed to comply with the law when they shared customers’ sensitive data with the government,” he told The Associated Press in a written statement Friday. Under law, the government can request information, such as the type of details that might be printed on a phone bill: the date and time of a call or text, a telephone calling card number, the duration of a call and to what phone number it was made. The details provided to the government do not include the content of any communications, the name, address or financial information of a customer, cell site location or GPS information.

We can assume that the “technical irregularities” in the data included some of that forbidden information. If that’s the case, Wyden may be right. There may have been some carelessness on the part of telecom companies in turning over data to the NSA.

I’m all for protecting the country from terrorists and rooting out foreign spies, but I find it astonishing that someone goofed up and allowed the NSA to access information that they are barred by law from possessing. It’s probably a pretty complex process, but is that really an excuse? It seems to me there should have been better checks and balances on both ends so that this sort of thing wouldn’t be possible.