fix(scheduler): detect auth-failure markers in session output#243
Open
brianjones-v4n wants to merge 1 commit into
Open
fix(scheduler): detect auth-failure markers in session output#243brianjones-v4n wants to merge 1 commit into
brianjones-v4n wants to merge 1 commit into
Conversation
Claude Code exits cleanly on 401 / invalid-auth responses, leaving session.status = 'completed'. Without scanning the output, the scheduler records these silent failures as successes — the job appears healthy while auth has actually broken. Scan the last 4 KB of captured output against a set of well-known auth-failure regex landmarks (401 Unauthorized, "Invalid API key", "Please re-authenticate", expired OAuth tokens, etc.). On hit, override failed = true and surface the matched fragment as the error reason in both runHistory.recordCompletion and the persisted lastError field. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@brianjones-v4n is attempting to deploy a commit to the sagemind Team on Vercel. A member of the Team first needs to authorize it. |
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.
Summary
Claude Code exits cleanly (status
completed, exit code 0) on a 401 / invalid-auth response. Without scanning the captured session output, the scheduler records these silent auth failures as successes — the job appears healthy while authentication is actually broken.This adds a post-completion scan of the last 4 KB of session output against well-known auth-failure regex landmarks:
401 Unauthorized/401 ... authenticationInvalid (authentication|API key|bearer token|x-api-key)UnauthorizedOAuth token has expired / is invalid / expired / missingAPI key not valid / found / providedPlease (re-)?authenticateOn hit:
failed = truerunHistory.recordCompletion'serrorfieldlastErrorfor the jobTest plan
AUTH_FAILURE_PATTERNSconst exists at module scope with expected regex landmarkslet failedso the override is possibleerrorandlastErrornpx tsc --noEmit— no new errors (9 pre-existing errors unchanged)🤖 Generated with Claude Code