{"record":{"id":"713d214344a13e0f","repo":"Hmbown/CodeWhale","slug":"custom-provider-name-is-reserved","errorCode":null,"errorMessage":"custom provider name is reserved","messagePattern":"custom provider name is reserved","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/config_persistence.rs","lineNumber":693,"sourceCode":"                } else {\n                    unset_document_value(doc, &[entry[0], entry[1], \"auth_mode\"])?;\n                }\n            }\n        }\n        Ok(())\n    })?;\n    Ok(path)\n}\n\nfn normalize_custom_provider_id(raw: &str) -> anyhow::Result<String> {\n    use anyhow::bail;\n\n    let value = raw.trim();\n    if value.is_empty() {\n        bail!(\"custom provider name is required\");\n    }\n    if value == \"__custom__\" {\n        bail!(\"custom provider name is reserved\");\n    }\n    if crate::config::ApiProvider::parse(value).is_some() {\n        bail!(\"custom provider name must not shadow a built-in provider\");\n    }\n    if !value\n        .chars()\n        .all(|ch| ch.is_ascii_alphanumeric() || matches!(ch, '_' | '-'))\n    {\n        bail!(\"custom provider name may only use letters, numbers, '-' and '_'\");\n    }\n    Ok(value.to_string())\n}\n\nfn normalize_custom_provider_base_url(raw: &str) -> anyhow::Result<String> {\n    use anyhow::bail;\n\n    let value = raw.trim().trim_end_matches('/');\n    if value.is_empty() {","sourceCodeStart":675,"sourceCodeEnd":711,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/config_persistence.rs#L675-L711","documentation":"normalize_custom_provider_id rejects the reserved sentinel name '__custom__', which marks the custom-provider slot internally and must never become a real provider id; using it as a name would collide with the sentinel.","triggerScenarios":"Calling persist_custom_provider with a name exactly \"__custom__\" (after trimming).","commonSituations":"A UI passes through its internal placeholder value when the user never replaced it with a real name.","solutions":["Pick a different name for the provider.","In UIs, treat \"__custom__\" as an unset placeholder and require a real name before saving."],"exampleFix":"// before\npersist_custom_provider(path, \"__custom__\", &url, ...)?;\n// after\npersist_custom_provider(path, \"my_gateway\", &url, ...)?;","handlingStrategy":"validation","validationCode":"if name.trim() == \"__custom__\" { return Err(anyhow::anyhow!(\"reserved name\")); }","typeGuard":"fn is_reserved(name: &str) -> bool { name.trim() == \"__custom__\" }","tryCatchPattern":"match persist_custom_provider(path, name, &url, ...) {\n    Err(e) if e.to_string().contains(\"reserved\") => prompt_for_different_name(),\n    other => other,\n}","preventionTips":["Never use \"__custom__\" as a provider name; it is a placeholder sentinel.","Replace UI placeholder values with real names before saving."],"tags":["validation","custom-provider","reserved-name"],"backgroundTag":"invalid-identifier","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T11:17:16.035Z"}