Fix seam-doctor crash under a non-UTF-8 locale - #1
Conversation
|
Warning Review limit reached
More reviews will be available in 31 minutes and 29 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 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 |
agent-workflow-seam-doctor read AGENTS.md with File.read, which decodes using the locale's default external encoding. Under a non-UTF-8 locale (e.g. LANG=C / LC_ALL=C, common in CI and headless agent shells) any non-ASCII byte in AGENTS.md (em dashes, arrows) raised "invalid byte sequence in US-ASCII" from String#match? while extracting the Agent Workflow Configuration section. That aborts the seam validation AGENTS.md mandates before issue/PR/batch work, so every adopting repo is exposed. Read AGENTS.md as UTF-8 and scrub, matching the idiom already used for skill/workflow markdown in executable_placeholder_issues. Add a regression test that runs the doctor against a non-ASCII AGENTS.md under LC_ALL=C. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
58395e8 to
cb71a54
Compare
Follow-up to #1. Two more standalone Ruby tools crashed under LANG=C / LC_ALL=C (common in CI and headless agent shells) with "invalid byte sequence in US-ASCII": - agent-workflows-status: metadata JSON read, VERSION read, and git capture decoded with the locale default encoding; died uncaught because the rescue only caught ArgumentError/RuntimeError, not EncodingError. - pr-batch/pr-security-preflight: run_gh returned raw gh stdout, so JSON.parse of gh issue/PR payloads crashed on non-ASCII issue bodies and author names. Both now force UTF-8 and scrub at the read/capture boundary, matching the seam-doctor idiom. Adds a LANG=C regression test for each (new agent-workflows-status-test.rb wired into bin/validate; a non-ascii-issue fixture for preflight) and a Troubleshooting note. bin/validate green.
Problem
agent-workflow-seam-doctoris the validationAGENTS.mdmandates before anyissue / PR / batch work. It crashes under a non-UTF-8 locale:
LANG=C/LC_ALL=Cis common in CI and headless agent shells. It passesinteractively only because dev shells default to
en_US.UTF-8.Root cause
checkreadAGENTS.mdwithFile.read(agents_path), which decodes using thelocale's default external encoding. Under a non-UTF-8 locale the string is
tagged US-ASCII, so the first non-ASCII byte (em dash, arrow, …) makes
String#match?raise whileextract_sectionscans the## Agent Workflow Configurationheading. Every adopting repo is affected,because real
AGENTS.mdfiles contain such bytes.Fix
Read
AGENTS.mdas UTF-8 andscrub, the same idiom already used forskill/workflow markdown in
executable_placeholder_issues(
File.binread(path).force_encoding("UTF-8").scrub). One line, no behaviorchange under a UTF-8 locale.
Testing
test_non_ascii_agents_md_parses_under_ascii_localewrites a non-ASCII
AGENTS.mdand runs the doctor withLC_ALL=C/LANG=C;it fails (the crash) before the fix and passes after.
bin/validateis green (40 runs, 101 assertions, 0 failures).LANG=C LC_ALL=C ... --root <react_on_rails>now returns
PASSinstead of crashing.Note
Other standalone Ruby helpers in
skills/*/bin/useFile.readtoo and maywarrant the same hardening; left out here to keep this fix focused.