fix: improve error handling when request receives non-JSON response#1477
Open
NeilSmithDLS wants to merge 6 commits intomainfrom
Open
fix: improve error handling when request receives non-JSON response#1477NeilSmithDLS wants to merge 6 commits intomainfrom
NeilSmithDLS wants to merge 6 commits intomainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1477 +/- ##
==========================================
+ Coverage 95.21% 95.22% +0.01%
==========================================
Files 43 43
Lines 3132 3141 +9
==========================================
+ Hits 2982 2991 +9
Misses 150 150 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
566bd02 to
ba9a28b
Compare
Alexj9837
reviewed
Apr 10, 2026
Comment on lines
109
to
119
| code = response.status_code | ||
| if response.content: | ||
| try: | ||
| response.json() | ||
| except json.decoder.JSONDecodeError: | ||
| return BlueskyRemoteControlError( | ||
| "Response does not contain a valid JSON object" | ||
| ) | ||
| if code < 400: | ||
| return None | ||
| elif code == 404: |
There was a problem hiding this comment.
What would happen if you got a 500 code, that held html?
tpoliaw
requested changes
Apr 10, 2026
Contributor
tpoliaw
left a comment
There was a problem hiding this comment.
I'm not sure the _exception method is the best place for this check to be, for instance running a plan uses the alternative _create_task_exceptions method and bypasses this check
$ # with config pointing to oauth-proxy
$ uv run blueapi -c path/to/config.yaml controller run --bg -i cm12345-3 sleep '{"time": 3}'
Error: task could not run: Expecting value: line 1 column 1 (char 0)
We're also parsing the json multiple times on the happy path when everything is working which isn't ideal.
Would it work to add a helper method to wrap wherever we're calling .json()?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
improve error handling when request receives non-JSON response.
Closes 1472