Skip to content

Conversation

@alden-olivero
Copy link

This pull request fixes a recurring issue where the SDK throws CLIJSONDecodeError due to incomplete or concatenated JSON objects in the subprocess output stream. The CLI occasionally emits partial or multiple JSON chunks across lines, which previously caused the parser to fail with json.decoder.JSONDecodeError: Extra data.

@ltawfik
Copy link
Collaborator

ltawfik commented Jun 18, 2025

Hey @alden-olivero , thanks for working on this JSON parsing issue!

A few problems that need fixing:

Bugs & issues:

  • There's a syntax error - the try was removed but except is still there
  • Missing space in json_buffer= ""
  • The buffer never gets cleared after successful parsing
  • No yield data after parsing succeeds
  • The buffer can grow infinitely - we need a size limit

The bracket counting approach breaks on valid JSON like:
{"message": "Use {} in your code"}

Suggestions:

  1. Add a max buffer size (like 1MB)
  2. Replace print() with proper logging
  3. Add tests for the edge cases
  4. Consider a different approach than counting brackets

@alden-olivero
Copy link
Author

alden-olivero commented Jun 18, 2025

Hey @alden-olivero , thanks for working on this JSON parsing issue!

Hi @ltawfik , I have taken all yours suggestions and have updated the code. Please go through it.

@ltawfik
Copy link
Collaborator

ltawfik commented Jun 27, 2025

thanks @alden-olivero . This PR still has critical bugs, will close for now and solve the issue in a separate PR.

@ltawfik ltawfik closed this Jun 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants