gastownhall/beads · error
credential command output is not a bare token (contains whit
Error message
credential command output is not a bare token (contains whitespace); expected a token or a JSON {token,expirationTimestamp} envelope What it means
Bare (non-JSON) credential output is accepted only as a single-line token. If the trimmed output contains any whitespace, it is rejected because multi-word output is almost always an error message that would fail confusingly when used as a credential.
Source
Thrown at internal/creds/command.go:175
token = c.AccessToken
}
if token == "" {
return "", "", time.Time{}, fmt.Errorf("credential command JSON has no token/access_token field")
}
switch {
case c.ExpirationTimestamp != "":
if t, perr := time.Parse(time.RFC3339, c.ExpirationTimestamp); perr == nil {
expiry = t
}
case c.ExpiresIn > 0:
expiry = time.Now().Add(time.Duration(c.ExpiresIn) * time.Second)
}
return token, c.Username, expiry, nil
}
bare := string(trimmed)
if strings.ContainsAny(bare, " \t\r\n") {
return "", "", time.Time{}, fmt.Errorf("credential command output is not a bare token (contains whitespace); expected a token or a JSON {token,expirationTimestamp} envelope")
}
return bare, "", time.Time{}, nil
}
View on GitHub (pinned to 71377f2769)
Solutions
- Run the credential command manually and look at its stdout — it is printing an error message, not a token.
- Fix the helper to send human-readable messages to stderr and write only the token to stdout.
- Re-authenticate if the message is an instruction to log in.
- Ensure no echo/logging statements in the helper script write to stdout.
Example fix
// before echo "Warning: token expires soon" echo "$TOKEN" // after echo "Warning: token expires soon" >&2 printf '%s' "$TOKEN"
Defensive patterns
Strategy: validation
Validate before calling
trimmed := bytes.TrimSpace(raw)
if len(trimmed) > 0 && trimmed[0] != '{' && strings.ContainsAny(string(trimmed), " \t\r\n") {
// multi-word output: helper is printing prose, not a token; fix first
} Prevention
- Write exactly one token with no trailing newline/formatting (use printf, not echo with extra text).
- Route all helper prose to stderr.
- Suppress ANSI color and prompts in non-interactive mode.
When it happens
Trigger: The helper prints a human-readable message on stdout instead of a token — e.g. 'Please run gh auth login', multi-line logs, or a token followed by a trailing explanation sentence.
Common situations: Helper writing warnings/prompt text to stdout instead of stderr; a script echoing instructions and then the token on separate lines; ANSI-colored or padded output from a wrapper.
Related errors
- credential command produced no output
- credential command returned unparseable JSON: %w
- dolt version output is unparseable
- parsing batch input: %w
- line %d: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/fa8e1bd8954febaa.
Report an issue: GitHub.