OK, I have replicated this problem and figured out the source. The mystery was why the percolator.target.psms.txt file contains references to decoy proteins. This file is supposed to contain only the targets. The answer is that some peptide sequences occur in both. E.g., the sequence ISILK appears in these proteins:
It is a bit strange that comet reports peptides that are both targets and decoys, but I suppose this is unavoidable when you use reversal to generate decoys. It's also strange that Percolator reports these decoy IDs in the target file. I will raise this as an issue with the Percolator authors. However, it seems clear that spectral-counts should be smarter about this. The error message it raises is
WARNING: Need protein sequence in order to calculate protein length.
Please provide protein fasta or index using the protein-database parameter
Protein decoy_tr|X2JLN4|X2JLN4_DROME doesn't have the full sequence
The program should notice that, in fact, a protein database was provided, and it should simply skip over proteins that do not appear in the given database. We'll work on fixing this.