Skip to content

Conversation

@patrickelectric
Copy link
Member

@patrickelectric patrickelectric commented Feb 9, 2026

image

Summary by Sourcery

Bug Fixes:

  • Ensure JSON decoding failures no longer get lumped together with HTTP and socket errors, allowing proper handling of binary or invalid JSON responses.

@sourcery-ai
Copy link

sourcery-ai bot commented Feb 9, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Refines error handling in simple_http_request to distinguish JSON decoding errors from HTTP/socket errors, adding more informative logging and error messages for JSON failures while preserving existing handling for other exceptions.

File-Level Changes

Change Details Files
Improve JSON decode error handling in simple_http_request while separating it from HTTP/socket exceptions.
  • Split the combined exception handler into a dedicated json.JSONDecodeError handler and a separate handler for HTTP and socket errors.
  • Log JSON decoding failures with a structured warning that includes the error message and position in the payload.
  • Set request_response.error to the JSON decode error message instead of the generic stringified exception for JSON errors.
  • Retain existing logging and error assignment behavior for HTTPException and socket.error in a separate except block.
core/services/helper/main.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `core/services/helper/main.py:264-266` </location>
<code_context>
             request_response.error = str(e)

-        except (http.client.HTTPException, socket.error, json.JSONDecodeError) as e:
+        except json.JSONDecodeError as e:
+            logger.warning(f"Failed to decode JSON response: {e.msg} (pos {e.pos})")
+            request_response.error = e.msg
+
+        except (http.client.HTTPException, socket.error) as e:
</code_context>

<issue_to_address>
**suggestion:** Consider using str(e) (or including pos) for the stored error to preserve full JSONDecodeError context

Using `str(e)` for `JSONDecodeError` preserves useful details like line/column/char (e.g. `Expecting value: line 1 column 1 (char 0)`), which are lost when using only `e.msg`. Since the log already includes position, consider keeping `request_response.error` consistent with previous behavior and other exceptions by using `str(e)` or including position explicitly (e.g. `f"{e.msg} (pos {e.pos})"`).

```suggestion
        except json.JSONDecodeError as e:
            logger.warning(f"Failed to decode JSON response: {e.msg} (pos {e.pos})")
            request_response.error = str(e)
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@patrickelectric patrickelectric force-pushed the fix-weird-output-broken-terminal branch from fa25c3b to 9edf83f Compare February 9, 2026 15:16
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
@patrickelectric patrickelectric force-pushed the fix-weird-output-broken-terminal branch from 9edf83f to c8c7f98 Compare February 9, 2026 17:58
@joaoantoniocardoso joaoantoniocardoso merged commit e1956ca into bluerobotics:master Feb 9, 2026
7 checks passed
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