{"record":{"id":"aa41355fefc55c3d","repo":"Hmbown/CodeWhale","slug":"invalid-codewhale-owned-xai-oauth-generation-expe","errorCode":null,"errorMessage":"invalid Codewhale-owned xAI OAuth generation; expected xai-auth-<32 lowercase hex>.json","messagePattern":"invalid Codewhale-owned xAI OAuth generation; expected xai-auth-<32 lowercase hex>\\.json","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/config/src/xai_credentials.rs","lineNumber":66,"sourceCode":"/// failed config mutation restores or retains the prior files; a successful\n/// mutation removes them.\n#[derive(Debug)]\npub struct XaiOAuthRevocation {\n    retired: Vec<(String, String)>,\n}\n\n#[must_use]\npub fn is_valid_xai_oauth_generation(value: &str) -> bool {\n    is_valid_owned_oauth_generation(\n        value,\n        XAI_OAUTH_GENERATION_PREFIX,\n        XAI_OAUTH_GENERATION_SUFFIX,\n    )\n}\n\npub fn validate_xai_oauth_generation(value: &str) -> Result<&str> {\n    if !is_valid_xai_oauth_generation(value) {\n        bail!(\n            \"invalid Codewhale-owned xAI OAuth generation; expected xai-auth-<32 lowercase hex>.json\"\n        );\n    }\n    Ok(value)\n}\n\n#[must_use]\npub fn is_valid_chatgpt_oauth_generation(value: &str) -> bool {\n    is_valid_owned_oauth_generation(\n        value,\n        CHATGPT_OAUTH_GENERATION_PREFIX,\n        CHATGPT_OAUTH_GENERATION_SUFFIX,\n    )\n}\n\npub fn validate_chatgpt_oauth_generation(value: &str) -> Result<&str> {\n    if !is_valid_chatgpt_oauth_generation(value) {\n        bail!(","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/config/src/xai_credentials.rs#L48-L84","documentation":"validate_xai_oauth_generation checks a generation filename against the strict pattern xai-auth-<32 lowercase hex>.json, where the 32 hex chars are a blake3 hash prefix identifying a stored OAuth generation. It is called by xai_oauth_generation_path and remove_xai_oauth_generation, so any programmatically constructed generation name must match exactly or the library refuses to touch the file.","triggerScenarios":"Calling xai_oauth_generation_path or remove_xai_oauth_generation with a value that is not exactly \"xai-auth-\" + 32 lowercase hex + \".json\" — e.g. uppercase hex, wrong length, missing prefix/suffix, or a path instead of the bare generation name.","commonSituations":"Parsing a directory listing and passing the full path rather than the file name, hand-editing a stored generation reference, or a version change in the hashing scheme producing a different-length digest.","solutions":["Pass only the bare generation file name, e.g. \"xai-auth-3f9a1c...c2.json\" (32 lowercase hex chars)","Lowercase and re-truncate any hash you computed to exactly 32 hex chars before calling","Strip any directory prefix from a path obtained by scanning the credentials directory"],"exampleFix":"// before\nremove_xai_oauth_generation(\"/home/u/.xai/xai-auth-3F9A1C.json\")\n// after\nremove_xai_oauth_generation(\"xai-auth-3f9a1c0d7e2b4a6f8d1c3e5a7b9d0f2b.json\")","handlingStrategy":"validation","validationCode":"fn is_xai_generation(v: &str) -> bool {\n    let hex = v.strip_prefix(\"xai-auth-\")\n        .and_then(|r| r.strip_suffix(\".json\"));\n    hex.map(|h| h.len() == 32 && h.chars().all(|c| c.is_ascii_hexdigit() && !c.is_ascii_uppercase()))\n        .unwrap_or(false)\n}","typeGuard":"fn as_xai_generation(v: &str) -> Option<&str> {\n    let hex = v.strip_prefix(\"xai-auth-\")?.strip_suffix(\".json\")?;\n    (hex.len() == 32 && hex.bytes().all(|b| b.is_ascii_hexdigit() && !b.is_ascii_uppercase()))\n        .then_some(v)\n}","tryCatchPattern":"match validate_xai_oauth_generation(value) {\n    Ok(v) => remove_xai_oauth_generation(v),\n    Err(e) => eprintln!(\"bad generation name '{value}': {e}\"),\n}","preventionTips":["Pass bare file names, never full paths","Downcase any hash you compute and truncate to 32 hex chars","Take generation names from the library's own listing APIs, not hand-built strings"],"tags":["config","oauth","validation","xai"],"backgroundTag":"invalid-identifier-format","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}