Repository navigation
Guard ruleset_id() Against Malformed Array Elements - #2036
Conversation
Fail loud when the ids extraction errors on an array of non-objects, and when a matching ruleset carries no id, rather than reading either as not found or reaching rulesets/null. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Repository: ptr727/ProjectTemplate/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2036 +/- ##
========================================
Coverage 55.66% 55.66%
========================================
Files 16 16
Lines 7317 7317
========================================
Hits 4073 4073
Misses 3244 3244
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The change is small, correct, and well-tested, but it modifies the fleet's branch-protection ruleset configuration tooling, a security-sensitive surface that warrants final human sign-off.
Review effort: Balanced
Findings: None
What changed in this PR
This PR hardens ruleset_id() in repo-config/configure.sh, the shared helper that maps a branch-protection ruleset name to its live id for the fleet's apply/check configuration tooling. It extends the existing "fail loud on an untrusted 2xx body" guard (which already handled non-array responses) to also reject malformed array elements: non-object entries (including null) and matching objects whose id is missing or not an integer. This prevents two silent misreads — treating a malformed live ruleset as "not found" (which would make apply create a duplicate ruleset) and resolving an id to the literal string null (which would PUT/read rulesets/null).
I verified the new jq filter against all ten test shapes with jq-1.7 (matches resolve, and every malformed shape errors with a non-zero exit), and confirmed both call sites abort correctly: the apply site's bare assignment (configure.sh:242) aborts via top-level set -e, and the check site (configure.sh:422) already uses if !. The change is a strict safety improvement with no behavioral change for well-formed API responses.
Changes:
- Guard the
ids=extraction withif ! ids="$(...)"and a jq filter that errors on any non-object element or non-integer matchedid, returning non-zero with a context message. - Add a parameterized test covering ten malformed-array shapes, asserting a non-zero exit, the "could not read live ruleset state" message, and that no
nullleaks to stdout.
| File | Description |
|---|---|
| repo-config/configure.sh | Replaces the unguarded ids= extraction with a fail-loud guard that rejects non-object elements and non-integer matched ids. |
| tests/test_configure_ruleset_id.py | Adds a subtest matrix exercising each malformed-array element shape and asserting ruleset_id aborts instead of misreading. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…pilot Coverage at Balanced Effort (#2105) ## Summary Promotes develop to main, carrying 14 pull requests: - [#2076](#2076) Read the Guard's Token Fallback With a Bash-Aware Context Scan - [#2081](#2081) Keep the Guard's Quote Mask When an Escape Sits Outside the Loop Condition - [#2094](#2094) Reconfigure pr_review.py's Console Streams to UTF-8 - [#2088](#2088) Guard check_settings' Live Read of the Repository Response - [#2102](#2102) Skip a Blockquoted List Marker in the Prose Gate's Dash Rule - [#2104](#2104) Accept a Head Round's Exact File Table as Copilot Coverage at Balanced Effort - [#2098](#2098) Quote the Review Engine's Remaining Bare Shell Placeholders - [#2050](#2050) Hand Unstated Coverage to the Maintainer Instead of Prescribing a Re-Request - [#2046](#2046) Report a Copilot Review Request That Records Nothing Instead of Waiting It Out - [#2053](#2053) State the Python Build Profile by Its Trait, Not One of Its Forms - [#2068](#2068) Strip the CR From configure.sh's Environment-Name Encoding - [#2033](#2033) Bound the Guard's Stdin Descriptor Before int() - [#2036](#2036) Guard ruleset_id() Against Malformed Array Elements - [#2039](#2039) Strip the CR From configure.sh's Workflow-Model Read The lead change is #2104. Copilot code review's default effort moved from Lite to Balanced on 2026-09-28, and Balanced rounds write a per-file table but almost never a coverage statement. `pr_review.py` now accepts a head round's file table as coverage when it names exactly the changed files and no Copilot round on the pull request has ever stated or appeared to state partial coverage. Before this, every pull request reviewed at Balanced effort parked on a maintainer decision. The other pull requests are guard, configure, prose-gate, and review-engine fixes that were waiting on that decision or landed earlier. #2076 leaves #1910, #1958, and #1959 open, per #1960. Closes #1998 Closes #2091 Closes #1260 Closes #1190 Closes #1652 Closes #2047 Closes #1904 Closes #1947 Closes #1882 Closes #2028 Closes #1987 Closes #1881 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Makes ruleset_id() fail loud on an array of non-objects (including null elements) and on a matching ruleset whose id is not an integer, rather than reading either as not found or reaching rulesets/null. Tests cover each shape and fail with the fix reverted.
Closes on promotion: #1987
🤖 Generated with Claude Code