Avoid caching when JQ filter call fails#191
Conversation
WalkthroughSystematic addition of error handling for jq filter operations across multiple library files. When a jq filter fails, the code now logs an error "Failed to execute the jq filter" and returns a non-zero exit code, preventing further processing with potentially invalid data. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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 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. |
|
not stale |
|
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. |
|
not stale |
There was a problem hiding this comment.
Pull request overview
This PR hardens Bashio’s “user-provided jq filter” paths by detecting jq execution failures and aborting early, so failed filter evaluations don’t end up cached (or silently propagated) across subsequent calls.
Changes:
- Add return-code checks after
bashio::jqcalls and return__BASHIO_EXIT_NOKon filter failures. - Prevent
bashio::cache.setfrom running when jq filter execution fails in the affected cached-info helpers. - Apply the same jq-failure handling to
bashio::api.supervisor()’s optional filter step.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| lib/supervisor.sh | Stop and return error when jq filtering fails before caching supervisor info/stats. |
| lib/os.sh | Stop and return error when jq filtering fails before caching OS info. |
| lib/observer.sh | Stop and return error when jq filtering fails before caching observer info/stats. |
| lib/network.sh | Stop and return error when jq filtering fails before caching network info/interface info. |
| lib/multicast.sh | Stop and return error when jq filtering fails before caching multicast info/stats. |
| lib/info.sh | Stop and return error when jq filtering fails before caching general system info. |
| lib/host.sh | Stop and return error when jq filtering fails before caching host info. |
| lib/hardware.sh | Stop and return error when jq filtering fails before caching hardware info. |
| lib/dns.sh | Stop and return error when jq filtering fails before caching DNS info/stats. |
| lib/core.sh | Stop and return error when jq filtering fails before caching core info/stats. |
| lib/cli.sh | Stop and return error when jq filtering fails before caching CLI info/stats. |
| lib/audio.sh | Stop and return error when jq filtering fails before caching audio info/stats. |
| lib/api.sh | Return error if optional jq filter application fails in Supervisor API calls. |
| lib/addons.sh | Stop and return error when jq filtering fails before caching add-on stats. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Proposed Changes
This is a continuation of #164 and #168.
I've added this protection only to those locations, where there is a "user" supported filter.
This was catched by coderabbitai here: #188 (comment)
Related Issues
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.