jupyter / nbformat

Reference implementation of the Jupyter Notebook format
http://nbformat.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
265 stars 152 forks source link

Only add ellipsis to NotJSONError message if message is truncated #344

Closed rschroll closed 1 year ago

rschroll commented 1 year ago

In almost all cases, it will be truncated, but in the few cases that parse_json is called with short invalid inputs, this prevents confusion about what actually got passed in.

Specifically, I ran into a case where nbformat was getting an empty string, rather than a valid JSON string, which produced the message

Notebook does not appear to be JSON: ''... which wrongly implies there is more to the input than there was.

It's a minor issue for sure, but I was poking around here anyway, so I thought I'd fix it.