Skip to content

Fix seam-doctor crash under a non-UTF-8 locale - #1

Merged
justin808 merged 1 commit into
mainfrom
jg/seam-doctor-utf8-locale-crash
Jun 25, 2026
Merged

Fix seam-doctor crash under a non-UTF-8 locale#1
justin808 merged 1 commit into
mainfrom
jg/seam-doctor-utf8-locale-crash

Conversation

@justin808

Copy link
Copy Markdown
Member

Problem

agent-workflow-seam-doctor is the validation AGENTS.md mandates before any
issue / PR / batch work. It crashes under a non-UTF-8 locale:

$ LANG=C LC_ALL=C ruby bin/agent-workflow-seam-doctor --root <repo>
agent-workflow-seam-doctor:122:in 'String#match?': invalid byte sequence in US-ASCII (ArgumentError)

LANG=C / LC_ALL=C is common in CI and headless agent shells. It passes
interactively only because dev shells default to en_US.UTF-8.

Root cause

check read AGENTS.md with File.read(agents_path), which decodes using the
locale'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 while extract_section scans the
## Agent Workflow Configuration heading. Every adopting repo is affected,
because real AGENTS.md files contain such bytes.

Fix

Read AGENTS.md as UTF-8 and scrub, the same idiom already used for
skill/workflow markdown in executable_placeholder_issues
(File.binread(path).force_encoding("UTF-8").scrub). One line, no behavior
change under a UTF-8 locale.

Testing

  • New regression test test_non_ascii_agents_md_parses_under_ascii_locale
    writes a non-ASCII AGENTS.md and runs the doctor with LC_ALL=C / LANG=C;
    it fails (the crash) before the fix and passes after.
  • bin/validate is green (40 runs, 101 assertions, 0 failures).
  • Verified against a real consumer repo: LANG=C LC_ALL=C ... --root <react_on_rails>
    now returns PASS instead of crashing.

Note

Other standalone Ruby helpers in skills/*/bin/ use File.read too and may
warrant the same hardening; left out here to keep this fix focused.

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@justin808, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 87ac6df4-1f2b-4cda-873f-bbd27519b69a

📥 Commits

Reviewing files that changed from the base of the PR and between d38645b and cb71a54.

📒 Files selected for processing (2)
  • bin/agent-workflow-seam-doctor
  • bin/agent-workflow-seam-doctor-test.rb
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jg/seam-doctor-utf8-locale-crash

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.

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>
@justin808
justin808 force-pushed the jg/seam-doctor-utf8-locale-crash branch from 58395e8 to cb71a54 Compare June 25, 2026 01:57
@justin808
justin808 merged commit b466a15 into main Jun 25, 2026
1 check passed
@justin808
justin808 deleted the jg/seam-doctor-utf8-locale-crash branch June 25, 2026 02:36
justin808 added a commit that referenced this pull request Jun 25, 2026
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.
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.

1 participant