Skip to content

Add error handling around JSON parsing of LLM responses #11

Description

@chenhaot

In agent.py, both analyze_issues() and review_codebase() call json.loads() on Claude's output without any try/except. If the model returns malformed JSON (markdown-wrapped, truncated, or with commentary), the bot crashes with an unhandled JSONDecodeError that propagates up to the Telegram handler.

This affects at least three code paths:

  • analyze_issues() (~line 77)
  • review_codebase() (~line 139)
  • Any caller that expects a list back gets an exception instead

Suggested fix: Wrap json.loads() in a try/except JSONDecodeError block. Log the raw response for debugging and return an empty list (or raise a domain-specific error with context). Also consider a more robust markdown-fence stripping regex, since the current approach only handles the exact pattern of backticks at start/end.


Identified by minbot code review

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions