I would have thought that this should never return bad data -- thats part of the point of using a cipher with authentication. But no, you're quite right, it returns garbage when you have a bad key.

This smells a little funny to me, as we probably shouldn't be relying on the fact that bad decryption produces invalid JSON. On the other hand, the only thing we rely on it for is an error message.

Need to think on this more.