Skip to content

Fix raw argument handling in Supervisor API call#190

Open
lmagyar wants to merge 4 commits intohassio-addons:mainfrom
lmagyar:pr-fix-su-raw
Open

Fix raw argument handling in Supervisor API call#190
lmagyar wants to merge 4 commits intohassio-addons:mainfrom
lmagyar:pr-fix-su-raw

Conversation

@lmagyar
Copy link
Copy Markdown
Contributor

@lmagyar lmagyar commented Jan 31, 2026

Proposed Changes

  • in case of POST, clear data from raw
  • there are urls, that return non-JSON plain text content, without .result and .data, like bashio::addon.logs(), documentation(), changelog(), in those cases do not search even for the .result or .data fields

Needs #192 to be merged to function properly.

Related Issues

Summary by CodeRabbit

  • Bug Fixes
    • Improved API error handling so responses are only treated as errors when appropriate to the request type.
    • Ensures raw POST payloads are cleared after use to prevent stale data from affecting subsequent requests.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jan 31, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 77fe8744-9e23-424c-8ddf-72ef1be4139c

📥 Commits

Reviewing files that changed from the base of the PR and between a97f0b1 and 61f503a.

📒 Files selected for processing (1)
  • lib/api.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/api.sh

Walkthrough

For POST requests in lib/api.sh, when raw input is provided it's now copied into data and raw is cleared. The response .result extraction and "error" check are performed only when raw is not truthy, changing the control flow for raw POSTs.

Changes

Cohort / File(s) Summary
API request handling
lib/api.sh
When handling POST with raw, set data="${raw}" and clear raw. Move/guard the .result extraction and "error" check so it runs only when raw is not truthy, altering error-detection flow for raw POSTs.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • frenck

Poem

🐰 I hopped through lines of script tonight,
Cleared a raw bit with a careful bite,
Now error checks wait out of sight,
POSTs hum along in softer light. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix raw argument handling in Supervisor API call' accurately summarizes the main change: fixing how the raw argument is handled in API calls, specifically by clearing data from raw POST requests and adjusting response validation logic.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@lmagyar
Copy link
Copy Markdown
Contributor Author

lmagyar commented Feb 1, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 1, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 4, 2026

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. Thank you for your contributions.

@github-actions github-actions bot added the stale There has not been activity on this issue or PR for quite some time. label Mar 4, 2026
@lmagyar
Copy link
Copy Markdown
Contributor Author

lmagyar commented Mar 4, 2026

not stale

@github-actions github-actions bot removed the stale There has not been activity on this issue or PR for quite some time. label Mar 5, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 4, 2026

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. Thank you for your contributions.

@github-actions github-actions bot added the stale There has not been activity on this issue or PR for quite some time. label Apr 4, 2026
@lmagyar
Copy link
Copy Markdown
Contributor Author

lmagyar commented Apr 4, 2026

not stale

@github-actions github-actions bot removed the stale There has not been activity on this issue or PR for quite some time. label Apr 5, 2026
@frenck frenck added the bugfix Inconsistencies or issues which will cause a problem for users or implementors. label Apr 7, 2026
@frenck frenck requested a review from Copilot April 7, 2026 13:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates bashio::api.supervisor to better distinguish between JSON API responses and “raw” (plain-text) endpoints, and to prevent POST payload handling from polluting the raw flag behavior.

Changes:

  • Clear the raw variable after it is repurposed as POST body data.
  • Add conditional logic intended to avoid checking .result/.message on responses that don’t follow the standard JSON envelope.
  • Use bashio::jq.exists as a guard before reading .result.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/api.sh Outdated
Comment thread lib/api.sh Outdated
This reverts commit a97f0b1.
@lmagyar
Copy link
Copy Markdown
Contributor Author

lmagyar commented Apr 13, 2026

Now it's ready for human review again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Inconsistencies or issues which will cause a problem for users or implementors.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants