JSONParser silently drops a document when chunk_size is negative
Reproduction
import asyncio
from core.parsers.structured.json_parser import JSONParser
async def main():
parser = JSONParser(None, None, None)
print([part async for part in parser.ingest('{"text":"hello"}', chunk_size=-1)])
asyncio.run(main())Actual: []. The JSON is valid and formats to nonempty text, but the negative range step yields no chunks. Expected: reject a negative chunk size rather than silently discard the document.
Proposed change
Validate a negative integer chunk_size before chunking. Preserve the existing None and 0 behavior, and normal positive-size chunking.
Validation
Inspected py/core/parsers/structured/json_parser.py on main, blob 3948e4de5f3c2a8332c3e2dd474e913dd0380dff. Python 3.13.5, Linux.
Executed the parser's inspected methods with real asyncio/JSON and minimal provider/base-class scaffolding: 3 failed / 6 passed before; 9 passed with the candidate validation. Coverage includes negative sizes, positive sizes, zero/default fallback, bytes input, and invalid JSON. Full R2R installation, providers, and repository-wide tests were not run. Issue and PR searches for chunk_size with negative did not find this case.
Source: SciPhi-AI/R2R