Skip to content

fix(auth): extract only token characters per line during claude setup-token reassembly#194

Merged
aaronjmars merged 1 commit into
aeonfun:mainfrom
antfleet-ops:fix/auth-route-token-reassembly
May 20, 2026
Merged

fix(auth): extract only token characters per line during claude setup-token reassembly#194
aaronjmars merged 1 commit into
aeonfun:mainfrom
antfleet-ops:fix/auth-route-token-reassembly

Conversation

@antfleet-ops

Copy link
Copy Markdown
Contributor

Fixes H5 from the AntFleet bench run — receipt: AntFleet#25 (comment)

What was wrong

claude setup-token output is captured as a string and sliced from sk-ant-oat onward. The reassembly loop then pushed line.trim() unconditionally for the first line, without restricting to token characters. If the terminal output included trailing prose after the token (e.g. sk-ant-oat01-abc… (valid for 30 days)) the whole trimmed string — including the non-token suffix — was appended, and subsequent continuation lines were concatenated on top of it. The result stored in CLAUDE_CODE_OAUTH_TOKEN was garbage.

Continuation lines used /^[A-Za-z0-9_\-]+$/ correctly, but the first line had no such guard.

Fix

Apply the same leading-match extraction (/^[A-Za-z0-9_\-]+/) to every line including the first. The regex takes only the token-alphabet prefix of the trimmed line and stops at the first foreign character — so prose, ANSI escapes, and spaces after the token are never included. A post-loop guard returns HTTP 400 if the assembled value doesn't start with sk-ant-oat, making extraction failures explicit instead of silently storing a malformed credential.

…-token reassembly

The prior loop pushed line.trim() unconditionally for the first line,
which included any trailing terminal prose, spaces, or ANSI sequences
that appeared after the token text on that line. Those bytes were
then concatenated into the stored CLAUDE_CODE_OAUTH_TOKEN, writing
a malformed credential to the GitHub secret.

Fix: apply the same /^[A-Za-z0-9_\-]+/ extraction to every line
(including the first). The regex anchors at the start of the trimmed
line and stops at the first non-token character, so only the token
alphabet is ever appended. Add a post-loop guard that returns a 400
if the assembled value does not start with "sk-ant-oat", making
extraction failures explicit instead of silently storing garbage.

Ref: AntFleet bench receipt AntFleet#25 (comment)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@imancipate

Copy link
Copy Markdown

Triage: ACCEPTED — clean against the contribution rubric (scope ✓ / format ✓ / originality ✓ / size ✓).
Thanks @antfleet-ops. A maintainer review pass will follow; in the meantime no changes requested from this triage layer.

@aaronjmars
aaronjmars merged commit e777f0a into aeonfun:main May 20, 2026
1 check passed
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.

4 participants