Skip to content

Guard ruleset_id() Against Malformed Array Elements - #2036

Merged
ptr727 merged 2 commits into
developfrom
feature/auto-1987
Sep 29, 2026
Merged

ptr727 merged 2 commits into
developfrom
feature/auto-1987

Conversation

@ptr727

@ptr727 ptr727 commented Sep 29, 2026

Copy link
Copy Markdown
Owner

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

ptr727 and others added 2 commits September 28, 2026 19:53
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]>
Copilot AI balanced review requested due to automatic review settings September 29, 2026 02:55
@coderabbitai

coderabbitai Bot commented Sep 29, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Repository: ptr727/ProjectTemplate/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 479ed5d4-2cfd-480a-b03a-d0ef54e00638


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.

@codecov

codecov Bot commented Sep 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.66%. Comparing base (c0467a5) to head (39d18ee).

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           
Flag Coverage Δ
python-3.13 55.66% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 with if ! ids="$(...)" and a jq filter that errors on any non-object element or non-integer matched id, 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 null leaks 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.

@ptr727
ptr727 merged commit ec3eb6a into develop Sep 29, 2026
11 checks passed
ptr727 added a commit that referenced this pull request Sep 29, 2026
…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)
@ptr727
ptr727 deleted the feature/auto-1987 branch October 17, 2026 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants