Repository navigation
fix(ci): pin UTF-8 when decoding clang-query output - #3747
Merged
Merged
Conversation
`subprocess.run(..., text=True)` without an explicit encoding decodes with
the locale codec. On Windows that is cp1252, so clang-query's UTF-8 output
raises UnicodeDecodeError inside the subprocess reader thread. The exception
does not propagate directly -- it leaves `result.stdout` as None, and the
caller then dies on `None + str`:
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
Net effect: the decayed-array-parameter ratchet and the FL_NO_EXCEPT ratchet
both crash instead of running for Windows contributors, so violations are
only caught later in CI.
Pin encoding="utf-8" with errors="replace" so a stray byte degrades to a
replacement character in a diagnostic rather than taking down the check.
Found while verifying a signature change against check_array_params.py.
Co-Authored-By: Claude <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughClang-query subprocess calls in two CI tools now explicitly decode output as UTF-8 and replace invalid bytes, avoiding locale-dependent decoding failures without changing subsequent parsing or error handling. ChangesClang-query decoding
Estimated code review effort: 2 (Simple) | ~5 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 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 |
zackees
added a commit
that referenced
this pull request
Jul 28, 2026
Found while checking PR #3749's new test against the ratchet. Running subprocess_capture_checker.py ci/tests/some_file.py reported "239 baselined subprocess usage(s) are now gone" -- because the improvement check compared the whole baseline against a single file's findings. Every entry for a file that was simply not examined counted as fixed. That message is wrong on its own, but the dangerous part is the action it invites: adding --update-baseline to that same narrow command rewrote the baseline from just that file, silently deleting the other 128 entries and turning the ratchet off across the repo. The next raw Popen would have gone in unnoticed. Both halves now key off the set of files actually scanned: - --update-baseline merges instead of overwriting, keeping entries for unscanned files verbatim. A file that genuinely improved still shrinks or drops out, so the ratchet can still be tightened incrementally. - The "now gone" note only counts entries for files this run looked at. Also drops the two check_array_params/check_noexcept SRC004 entries that #3747 resolved -- the baseline was generated just before that merged, so it was stale by exactly those two. Tests cover the narrow-update case, the misleading note, that a rescanned file can still shrink, and that a genuinely new violation still fails. The first three fail against the previous implementation. Validated: 556 passed / 39 skipped in ci/tests, lint green. Co-Authored-By: Claude <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ci/tools/check_array_params.pyandci/tools/check_noexcept.pyboth call:text=Truewith noencodingdecodes using the locale codec. On Windows that is cp1252, and clang-query emits UTF-8. The decode raises inside the subprocess reader thread, which does not propagate as a clean error — it leavesresult.stdoutasNone, so the next line fails:Impact
Both AST ratchets crash instead of running for Windows contributors:
array_param_baseline.txt)FL_NO_EXCEPTratchetSo new violations of either rule aren't caught locally and only surface later in CI.
Fix
Pin
encoding="utf-8"witherrors="replace"at both call sites.errors="replace"means a stray byte degrades to a replacement character inside a diagnostic string rather than taking down the whole check — these are error-reporting paths, so failing to decode one byte should never be fatal.Validation
uv run python ci/tools/check_array_params.py --scope allgoes from the traceback above to completing normally:bash lintgreen (ruff + ty pass).Note: I did not act on that "2 stale entries" hint. Regenerating the baseline locally drops two entries in files this branch never touched, which suggests the local run under-detects relative to CI rather than that the entries are genuinely dead. Pruning it belongs in a separate change made from a run that's trusted to be complete.
Found while verifying a signature change on #3746.
🤖 Generated with Claude Code
Summary by CodeRabbit