{"record":{"id":"7abe7775e550a5f3","repo":"Hmbown/CodeWhale","slug":"invalid-codewhale-owned-chatgpt-oauth-generation-expected","errorCode":null,"errorMessage":"invalid Codewhale-owned ChatGPT OAuth generation; expected chatgpt-auth-<32 lowercase hex>.json","messagePattern":"invalid Codewhale-owned ChatGPT OAuth generation; expected chatgpt-auth-<32 lowercase hex>\\.json","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/config/src/xai_credentials.rs","lineNumber":84,"sourceCode":"        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!(\n            \"invalid Codewhale-owned ChatGPT OAuth generation; expected chatgpt-auth-<32 lowercase hex>.json\"\n        );\n    }\n    Ok(value)\n}\n\nfn is_valid_owned_oauth_generation(value: &str, prefix: &str, suffix: &str) -> bool {\n    let path = Path::new(value);\n    if path.components().count() != 1\n        || !matches!(path.components().next(), Some(Component::Normal(_)))\n        || path.file_name().and_then(|name| name.to_str()) != Some(value)\n    {\n        return false;\n    }\n    let Some(id) = value\n        .strip_prefix(prefix)\n        .and_then(|value| value.strip_suffix(suffix))\n    else {","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/config/src/xai_credentials.rs#L66-L102","documentation":"validate_chatgpt_oauth_generation is the ChatGPT twin of the xAI validator: it requires exactly \"chatgpt-auth-<32 lowercase hex>.json\" before chatgpt_oauth_generation_path or remove_chatgpt_oauth_generation will act on the value. The 32 hex chars identify a stored ChatGPT OAuth generation file owned by Codewhale.","triggerScenarios":"Calling chatgpt_oauth_generation_path or remove_chatgpt_oauth_generation with a malformed generation name — wrong prefix (e.g. xai-auth-...), uppercase hex, wrong digest length, missing .json suffix, or a full path.","commonSituations":"Confusing the xAI and ChatGPT generation formats when scripting cleanup, passing directory-scanning results that include paths, or older stored references predating the strict naming convention.","solutions":["Pass the bare file name matching \"chatgpt-auth-\" + 32 lowercase hex + \".json\"","Make sure you're using the ChatGPT API, not the xAI one, for chatgpt-auth files","Regenerate the OAuth generation via the normal flow instead of hand-crafting the name"],"exampleFix":"// before\nchatgpt_oauth_generation_path(\"xai-auth-3f9a1c0d7e2b4a6f8d1c3e5a7b9d0f2b.json\")\n// after\nchatgpt_oauth_generation_path(\"chatgpt-auth-3f9a1c0d7e2b4a6f8d1c3e5a7b9d0f2b.json\")","handlingStrategy":"validation","validationCode":"fn is_chatgpt_generation(v: &str) -> bool {\n    let hex = v.strip_prefix(\"chatgpt-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_chatgpt_generation(v: &str) -> Option<&str> {\n    let hex = v.strip_prefix(\"chatgpt-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_chatgpt_oauth_generation(value) {\n    Ok(v) => chatgpt_oauth_generation_path(v),\n    Err(e) => eprintln!(\"bad generation name '{value}': {e}\"),\n}","preventionTips":["Don't mix up the xai-auth- and chatgpt-auth- prefixes when scripting","Pass bare file names, never paths or URLs","Prefer the library's list/remove helpers over manual directory scanning"],"tags":["config","oauth","validation","chatgpt"],"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"}