{"record":{"id":"e356c19bdcb5998b","repo":"Hmbown/CodeWhale","slug":"invalid-model-id-for-model-context-windows","errorCode":null,"errorMessage":"invalid model id for `model_context_windows`","messagePattern":"invalid model id for `model_context_windows`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/config/src/lib.rs","lineNumber":2670,"sourceCode":"            \"kind\"\n        } else {\n            ProviderConfigField::parse(field_key).map_or(field_key, |field| field.key())\n        };\n        table.remove(leg);\n    }\n\n    /// Write one `[providers.<id>.model_context_windows]` entry (#6108),\n    /// whether `<id>` is a built-in provider key or a named custom table.\n    fn set_model_context_window(\n        &mut self,\n        provider_id: &str,\n        model: &str,\n        value: &str,\n    ) -> Result<()> {\n        if model.eq_ignore_ascii_case(\"auto\")\n            || model.chars().any(|c| c.is_whitespace() || c.is_control())\n        {\n            bail!(\"invalid model id for `model_context_windows`\");\n        }\n        let window = parse_context_window(value)?;\n        if let Some(kind) = builtin_provider_kind_for_config_id(provider_id) {\n            self.providers\n                .for_provider_mut(kind)\n                .model_context_windows\n                .insert(model.to_string(), window);\n            return Ok(());\n        }\n        let table = self.custom_provider_table_mut(provider_id)?;\n        let windows = table\n            .entry(\"model_context_windows\".to_string())\n            .or_insert_with(|| toml::Value::Table(toml::value::Table::new()));\n        windows\n            .as_table_mut()\n            .with_context(|| {\n                format!(\"providers.{provider_id}.model_context_windows must be a table\")\n            })?","sourceCodeStart":2652,"sourceCodeEnd":2688,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/config/src/lib.rs#L2652-L2688","documentation":"Keys of the form model_context_windows.<provider>.<model> are validated before the window value: the model id may not be the literal `auto` and may not contain whitespace or control characters. `auto` is a reserved sentinel and malformed ids would create entries that never match a real model.","triggerScenarios":"set_model_context_window called with model == \"auto\" (case-insensitive) or a model string containing spaces/tabs/control characters — e.g. `config set model_context_windows.openai.some model 200000`.","commonSituations":"Trying to set a wildcard/default window using `auto`; pasting a model name with a stray space or line break from docs; shell quoting issues injecting whitespace into the key.","solutions":["Use the exact model id without spaces (quote the whole key in your shell)","Do not use `auto` as a model key; set the provider-level default context_window instead","Verify the model id matches what the provider API returns (e.g. gpt-4o, not \"gpt 4o\")"],"exampleFix":"// before\ncodewhale config set 'model_context_windows.openai.auto' 128000\n// after\ncodewhale config set 'model_context_windows.openai.gpt-4o' 128000","handlingStrategy":"validation","validationCode":"if model.eq_ignore_ascii_case(\"auto\") || model.chars().any(|c| c.is_whitespace() || c.is_control()) {\n    return Err(\"invalid model id for model_context_windows\");\n}","typeGuard":"fn valid_model_key(model: &str) -> bool {\n    !model.eq_ignore_ascii_case(\"auto\") && !model.chars().any(|c| c.is_whitespace() || c.is_control())\n}","tryCatchPattern":"match config.set_model_context_window(provider, model, value) {\n    Err(e) if e.to_string().contains(\"invalid model id\") => eprintln!(\"use exact model id, no spaces, not 'auto'\"),\n    other => other?,\n}","preventionTips":["Quote dotted keys in shell commands","Take model ids from provider API listings, not prose","Never use `auto` as a per-model key; use provider-level defaults"],"tags":["config","model","validation"],"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-22T16:17:23.217Z"}