-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correction to http_request
example
#4543
Conversation
The affected example code caused two errors: - a `no return statement in function returning non-void [-Werror=return-type]` caused by missing `return`s within the `if`s. - `while parsing a block mapping ... expected <block end>, but found '<scalar>'` caused by the `;` at the end of `args`
WalkthroughThe pull request modifies the error handling and logging mechanism in the Changes
Suggested reviewers
Possibly related PRs
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
components/http_request.rst (1)
294-301
: Improve error handling and documentation clarity.
- Fix the indentation to be consistent with the rest of the code example.
- Enhance the error message by including the actual JSON response for better debugging.
- Document the boolean return values in the example's description.
Apply this diff:
- if (root["vol"]) { - id(player_volume).publish_state(root["vol"]); - return true; - } - else { - ESP_LOGI(TAG,"No 'vol' key in this json!"); - return false; - } + if (root["vol"]) { + id(player_volume).publish_state(root["vol"]); + return true; + } + else { + ESP_LOGI(TAG, "No 'vol' key found in JSON response: %s", body.c_str()); + return false; + }Also, add this description above the code example:
The lambda function returns `true` if the "vol" key is found and processed successfully, and `false` otherwise.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
components/http_request.rst
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
components/http_request.rst (1)
Pattern **
: - Do not generate or add any sequence diagrams
✅ Deploy Preview for esphome ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
The affected example code caused two errors:
no return statement in function returning non-void [-Werror=return-type]
caused by missingreturn
s within theif
s.while parsing a block mapping ... expected <block end>, but found '<scalar>'
caused by the;
at the end ofargs
Also matched the example with the one at https://esphome.io/components/json#parsing-json
Description:
Related issue (if applicable): fixes
Pull request in esphome with YAML changes (if applicable): esphome/esphome#
Checklist:
I am merging into
next
because this is new documentation that has a matching pull-request in esphome as linked above.or
I am merging into
current
because this is a fix, change and/or adjustment in the current documentation and is not for a new component or feature.Link added in
/index.rst
when creating new documents for new components or cookbook.