gastownhall/beads · error
credential command produced no output
Error message
credential command produced no output
What it means
parseCredential parses the raw bytes returned by the credential command. If the trimmed output is empty, there is no token to extract, so this error is thrown. It guards against helpers that succeed silently (exit 0) but print nothing.
Source
Thrown at internal/creds/command.go:147
if expiry.IsZero() {
expiry = now.Add(credDefaultTTL)
}
credCacheMu.Lock()
credCache[command] = cachedCred{token: token, username: username, expires: expiry}
credCacheMu.Unlock()
return token, username, expiry, nil
}
// parseCredential extracts the token (and any username/expiry) from a helper's
// stdout. A JSON object is read as the ExecCredential/getToken envelope; otherwise
// the trimmed output is taken as a bare token. A bare value containing whitespace is
// rejected — it is almost always an error message, and using it as a credential
// would only fail confusingly downstream.
func parseCredential(raw []byte) (token, username string, expiry time.Time, err error) {
trimmed := bytes.TrimSpace(raw)
if len(trimmed) == 0 {
return "", "", time.Time{}, fmt.Errorf("credential command produced no output")
}
if trimmed[0] == '{' {
var c execCredential
if jerr := json.Unmarshal(trimmed, &c); jerr != nil {
return "", "", time.Time{}, fmt.Errorf("credential command returned unparseable JSON: %w", jerr)
}
token = c.Token
if token == "" {
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 = tView on GitHub (pinned to 71377f2769)
Solutions
- Run the credential command manually and confirm it prints a token or JSON envelope on stdout.
- Re-authenticate the helper (e.g. `gh auth login`, `docker login`).
- Check the configured credential command — a wrong or stub command may produce no output.
- Verify the helper supports the requested host/repository and is not silently no-oping.
Example fix
// before
#!/bin/sh
# helper prints nothing
echo -n ""
// after
#!/bin/sh
echo -n "{\"token\":\"ghp_xxx\",\"expirationTimestamp\":\"2026-01-01T00:00:00Z\"}" Defensive patterns
Strategy: validation
Validate before calling
out, err := exec.Command(helper, args...).Output()
if err == nil && len(bytes.TrimSpace(out)) == 0 {
// helper produced no output; re-authenticate or fix helper first
} Prevention
- Ensure the helper always writes a token to stdout on success.
- Send helper diagnostics to stderr, never stdout.
- Re-authenticate when logged out; verify with a manual run of the command.
When it happens
Trigger: The credential command exits 0 but writes nothing to stdout — e.g. an unauthenticated helper that prints its message to stderr only, or a script with an empty success path.
Common situations: Credential helper logged out but returning success; a wrapper script swallowing stdout; wrong command configured that prints nothing for the given host.
Related errors
- credential command returned unparseable JSON: %w
- credential command output is not a bare token (contains whit
- 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/6f85447417f10307.
Report an issue: GitHub.