Repository navigation
Tell Apart the Causes a Labels Payload Is Refused For - #2230
Conversation
Refuse a repeated label name and an uppercase hex color, which GitHub stores lowercased, and report an unparseable payload, a non-array, an empty array, an out-of-contract label, a repeated name, and a failing jq each as what it is instead of one message. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Read a payload as exactly one JSON document, tell a jq failure from a parse error at the first step, treat null as not an array, and compare names ignoring case, since GitHub does. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
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 #2230 +/- ##
==========================================
Coverage ? 56.61%
==========================================
Files ? 16
Lines ? 7482
Branches ? 0
==========================================
Hits ? 4236
Misses ? 3246
Partials ? 0
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
It changes shared fleet tooling that gates configuration writes and relies on subtle, jq-version-dependent exit-code and error-message behavior, so a maintainer should confirm it before merge.
Review effort: Balanced
Findings: None
What changed in this PR
This PR hardens labels_payload_ok, the shared pre-flight validator for repo-config/labels.json in the fleet configuration script. Previously the predicate folded every failure cause into a single boolean with suppressed jq stderr, admitted duplicate label names and uppercase hex colors (both of which later read as permanent drift against GitHub's lowercased, name-unique storage), and could blame a valid payload when jq itself failed (for example a build lacking test/1). The function now runs each check as its own step, reports the specific cause, rejects case-insensitive duplicate names and uppercase hex, and distinguishes a jq failure from a bad payload. This addresses the three defects tracked in the linked issue; remaining tightening is deferred to a follow-up issue.
Changes:
- Rewrote
labels_payload_okinto an ordered sequence ofjqsteps (parse, exactly-one-document, array, non-empty, field contract with lowercase-only hex, unique-name-ignoring-case), each emitting its own reason and separating ajqexecution failure from a payload defect. - Wired the returned reason into
cmd_applyandcheck_labelsviaif ! why="$(labels_payload_ok)", so the abort/drift message names the specific cause. - Added
LabelsPayloadCasetests exercising the lifted function against constructed payloads (duplicate names, case-folded duplicates, uppercase color, each parse/structure cause, and a stubbed failingjq), plus a test that the committedlabels.jsonstill passes.
| File | Description |
|---|---|
repo-config/configure.sh |
Splits labels_payload_ok into per-cause steps with lowercase-hex and unique-name checks; callers surface the specific reason. |
tests/test_configure_project.py |
New LabelsPayloadCase lifting the function to assert each refusal cause and that the committed payload is admitted. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
## Summary Promotes develop to main, carrying the pull requests below, each already reviewed and merged into develop. - [#2203](#2203): Strip every heredoc body a line opens in the wait-loop rule. - [#2216](#2216): Point the charset-unknown message at where a tier is classified. - [#2218](#2218): Name the leftover old tree when the Bash loader cannot remove it. - [#2227](#2227): End the guard's stdin redirect scan at a trailing comment. - [#2230](#2230): Tell apart the causes a labels payload is refused for. - [#2232](#2232): Correct the task names and pointers in the Python tasks snippet header. - [#2234](#2234): Drop the stale private-repository note from PhotoCleaner's registry entry. - [#2237](#2237): State the bootstrap's archive live channel in two skills. - [#2239](#2239): Stop the promotion count on a failed fetch in backlog-burndown. - [#2241](#2241): Render the include walk once per `build_dist.py --check` run. - [#2243](#2243): Have the tree check call `escapes_repo_root` and refuse a symlinked component. - [#2247](#2247): Refuse a Windows drive component anywhere in a tree path. - [#2222](#2222): Tick the adopted repos in the merge-bot and gate rollout stages. - [#2121](#2121): Refuse a dangling remote-tracking target in `local_review`. - [#2249](#2249): Ignore a quoted separator when the guard finds a loop's `done`. Closes #2112 Closes #2171 Closes #1790 Closes #2152 Closes #1372 Closes #2149 Closes #1082 Closes #1772 Closes #1310 Closes #1379 Closes #1452 Closes #2244 Closes #2168 Closes #2106 Closes #2207 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Closes on promotion: #1372
labels_payload_oknow refuses a repeated label name (ignoring ASCII case) and an uppercase hex color, since GitHub stores colors lowercased (confirmed read-only against this repository's labels). It checks the payload in separate steps and reports each cause as itself: did not parse, not exactly one JSON document, not an array, empty, outside the field contract, repeated name, and a failing jq.cmd_applyandcheck_labelsprint that reason.Tests in
LabelsPayloadCaseuse constructed payloads and fail on the old code. The comment change needs thecommentslabel.Remaining gaps the local review found are filed as #2229.
🤖 Generated with Claude Code