fix(tests): reject unreadable RD preset schemas - #4191
myasnikovdaniil wants to merge 1 commit into
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: cozystack/cozystack/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughThe preset checker now captures and reports jq errors when it cannot read a schema, marks that schema check as failed, and continues to the next schema. Its Bats tests cover schema failures, absent schemas, canonical preset checks, and large output. ChangesPreset check reliability
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The checker retains safe preset matching and reports schema-read failures; the added tests cover these behaviors. No concrete merge-blocking regression is established. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 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 |
|
The Broken pipe in those logs is not the jq pipe. It's line 39, the preset loop: if ! printf '%s\n' "$enums" | grep -Fqx -- "$want"; then
bash names the last line of a multi-line command in that message, so the jq substitution would have reported line 32: $ cat -n t.sh
5 out=$(printf '%s\n' "$big" \
6 | head -n 1 \
7 || true)
9 printf '%s\n' "$big" | grep -Fqx -- "1"
$ bash t.sh
t.sh: line 7: printf: write error: Broken pipe
t.sh: line 9: printf: write error: Broken pipeThe one-preset FAIL says the same. Truncated jq output is a prefix, so everything past the cut goes missing at once, and Line 39 needs the same here-string you gave jq: if ! grep -Fqx -- "$want" <<<"$enums"; thenWithout that the check keeps going red after this merges, with a different file and preset each time. |
654c6dd to
39f4c34
Compare
|
This is now stopping E2E from starting on other PRs, not only reddening the unit lane. On #3802 two runs died the same way with a different victim each time, and Both presets are present in those files and This PR and #4194 rewrite the same membership check, so whichever lands second conflicts on that line. Which of the two should go in? |
|
The here-string part landed in #4204, so after a rebase that line resolves to what main has. The jq status guard and the bats suite are still new. Main has no test for this script, so both are worth keeping. |
Discarding jq's exit status lets malformed schemas pass the preset check or turns a partial read into a misleading missing-preset report. Assisted-by: LLM Signed-off-by: Myasnikov Daniil <[email protected]>
39f4c34 to
47fe046
Compare
What this PR does
rd-presets-checkdiscardsjqerrors, so malformed schema can pass the check or appear as missing presets. It now fails with the schema path andjqdiagnostic. An absent schema or a readable schema withoutresourcesPresetis still skipped.Regression tests use real
jqfor malformed input and partial output. They also cover the canonical preset set, exact matching and the long-list case fixed by #4204.Testing
make unit-tests -j4 --output-sync=targetpassed.hack/check-rd-presets_test.bats, run withbatsanddash hack/cozytest.sh.main. Eleven deliberate code mutations also fail the expected test.shellcheck hack/check-rd-presets.sh hack/check-rd-presets_test.bats.Screenshots
Not applicable.
Downstream repositories
No files or make targets were moved or renamed. The change is limited to the RD checker and its tests.
Release note