Add support for 500 and 429 status codes#620
Conversation
📝 WalkthroughWalkthroughAdds handling for HTTP 429 (Too Many Requests) to JSON error processing and adds handling for HTTP 500 (Internal Server Error) to return a supervisor-log diagnostic when the response is not JSON. Also reorders imports (non-functional). Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to data retention organization setting
📒 Files selected for processing (1)
client/client.go(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
*/**(html|markdown|md)
⚙️ CodeRabbit configuration file
*/**(html|markdown|md): - For instructional content in documentation, use a direct and authoritative tone. Avoid expressions of politeness such as 'may' or 'please', and ensure the goal of the instruction is fronted.
- Apply the Microsoft Style Guide to ensure documentation maintains clarity and conciseness.
- In step-by-step instructions, front the location phrase in the instructional sentence.
- In step-by-step instructions, front the 'goal' in the instructional sentence.
- In step-by-step instructions, if in doubt what to front, front the 'goal' before the location phrase in the instructional sentence.
- do not hyphenate terms like 'top-right' or 'bottom-left' with 'corner'
*/**(html|markdown|md): - Use bold to mark UI strings.
If "" are used to mark UI strings, replace them by bold.
Be brief in your replies and don't add fluff like "thank you for..." and "Please let me know if"
Use sentence-style capitalization also in headings.
do not comment on HTML used for icons
Avoid flagging inline HTML for embedding videos in future reviews for this repository.
Files:
client/client.go
🔇 Additional comments (2)
client/client.go (2)
8-10: Import alias for logrus is appropriateUsing the
logalias matches existinglog.WithFieldusage and is idiomatic; no issues here.
24-28: Adding 429 to JSON-handled statuses is correctTreating
http.StatusTooManyRequestslike the other JSON error statuses and enforcing a JSONContent-Typeis consistent with the Supervisor behavior and the surrounding logic.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
sairon
left a comment
There was a problem hiding this comment.
Looks good, added the missing quote from the bot's suggestion.
Supervisor can now return 500 and 429 status codes under normal circumstances as of home-assistant/supervisor#6303 . This adds support for them to the CLI.
500 is extremely generic and is also returned in case of catastrophic failure by aiohttp. Therefore added support for a potential non-JSON response to handle that case somewhat sensibly.
Summary by CodeRabbit