Hmbown/CodeWhale · error · anyhow::Error
xAI/Grok credential file {} must be a JSON object of entries
Error message
xAI/Grok credential file {} must be a JSON object of entries What it means
Shape guard in parse_auth_file: the xAI/Grok credential file parsed as JSON but is not a JSON object of entries — it may be an array, string, or scalar. The schema contract requires an object keyed by entry names.
Source
Thrown at crates/tui/src/xai_oauth.rs:830
) -> Result<AuthFile> {
let Some(raw) = crate::external_credentials::read_to_string(grant)? else {
bail!(
"external xAI/Grok credential file not found at {}",
codewhale_config::quote_os_path(grant.path())
);
};
parse_auth_file(&raw, grant.path())
}
fn parse_auth_file(raw: &str, path: &Path) -> Result<AuthFile> {
let value: Value = serde_json::from_str(raw).map_err(|_| {
anyhow::anyhow!(
"xAI/Grok credential file {} is not valid credential JSON",
codewhale_config::quote_os_path(path)
)
})?;
let obj = value.as_object().ok_or_else(|| {
anyhow::anyhow!(
"xAI/Grok credential file {} must be a JSON object of entries",
codewhale_config::quote_os_path(path)
)
})?;
let mut out = BTreeMap::new();
for (k, v) in obj {
match serde_json::from_value::<GrokAuthEntry>(v.clone()) {
Ok(entry) => {
out.insert(k.clone(), entry);
}
Err(_) => {
tracing::warn!(
target: "codewhale::xai_oauth",
"skipping unreadable xAI auth entry"
);
}
}
}View on GitHub (pinned to 0c42157ee5)
Solutions
- Rewrite the credential file as a JSON object whose values are entry objects.
- Re-authenticate (`grok login` or `codewhale auth xai-device`) to regenerate a correctly shaped file.
- Check for incompatible tool versions that may have written an outdated schema.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/tui/src/xai_oauth.rs:830 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20).
Data as JSON: /api/errors/e166314454537992.
Report an issue: GitHub.