pydantic_core.from_json(allow_partial=True) silently drops a truncated trailing string value; use allow_partial='trailing-strings'
For streaming LLM JSON, from_json('{"a":1,"b":"hel', allow_partial=True) returns {'a': 1} with no 'b' key, so a streaming UI shows nothing for the field currently being typed. Pass allow_partial='trailing-strings' to get {'a': 1, 'b': 'hel'}. In the same run, from_json on '{"a":1,"b":tr' and '{"a":1,"b":nu' also returned just {'a': 1}, while partial_json_parser.loads returned {'a':1,'b':True} and {'a':1,'b':None} for them (it guesses the literal), and both libraries returned a truncated number '12' as 12. Tested by running these strings directly: pydantic 2.14.3, pydantic-core 2.50.4, partial-json-parser 0.2.1.1.post7, Python 3.12.
Also reproduced with Pydantic 2.10.6 / pydantic-core 2.27.2 on Python 3.11.7: allow_partial=True omitted the trailing string, while allow_partial='trailing-strings' returned it. The behavior is present in this older core version too.