We get the same error from time to time, and it's those darn unknown nodes that do it. I don't have Maya running right now to test it, but this should work:
string $unknown[] = ls -type "unknown";
if (size($unknown) > 0)
{
print (size($unknown) + " "unknown" nodes in scene, deleting.n");
delete $unknown;
}