{"record":{"id":"1b0fa5b9c075925e","repo":"Hmbown/CodeWhale","slug":"name-context-window-must-be-greater-than-0","errorCode":null,"errorMessage":"{name}.context_window must be greater than 0","messagePattern":"(.+?)\\.context_window must be greater than 0","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/config.rs","lineNumber":4078,"sourceCode":"            (\"providers.meta\", &self.meta),\n            (\"providers.xai\", &self.xai),\n        ];\n        for (name, config) in builtins {\n            validate_provider_context_window(name, config.context_window)?;\n            validate_model_context_windows(name, config.model_context_windows.as_ref())?;\n        }\n        for (name, config) in &self.custom {\n            let name = format!(\"providers.{name}\");\n            validate_provider_context_window(&name, config.context_window)?;\n            validate_model_context_windows(&name, config.model_context_windows.as_ref())?;\n        }\n        Ok(())\n    }\n}\n\nfn validate_provider_context_window(name: &str, value: Option<u32>) -> Result<()> {\n    if value == Some(0) {\n        anyhow::bail!(\"{name}.context_window must be greater than 0\");\n    }\n    Ok(())\n}\n\nfn validate_model_context_windows(\n    name: &str,\n    table: Option<&std::collections::BTreeMap<String, u32>>,\n) -> Result<()> {\n    if let Some(table) = table {\n        for (model, window) in table {\n            if *window == 0 {\n                anyhow::bail!(\"{name}.model_context_windows.{model} must be greater than 0\");\n            }\n        }\n    }\n    Ok(())\n}\n","sourceCodeStart":4060,"sourceCodeEnd":4096,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/config.rs#L4060-L4096","documentation":"Provider config validation rejects a context_window explicitly set to 0. Context windows must be positive (or left unset to use the default); zero is meaningless and would break token budgeting. Thrown by validate_provider_context_window at config.rs:4078.","triggerScenarios":"A provider entry in config has `context_window = 0` (only Some(0) triggers; None and positive values pass).","commonSituations":"Computing the window from an env/CLI value that defaulted to 0; copy-paste of a template with a placeholder 0; a script generating config where a lookup failed and yielded 0.","solutions":["Set context_window to a positive integer matching the provider's real limit (e.g. 200000).","Remove the key entirely to use the library default.","Fix the upstream source (env var or script) that produced 0."],"exampleFix":"// before\n[providers.myprovider]\ncontext_window = 0\n// after\n[providers.myprovider]\ncontext_window = 200000","handlingStrategy":"validation","validationCode":"if let Some(w) = provider.context_window {\n    if w == 0 { return Err(\"context_window must be > 0\"); }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Omit context_window rather than writing 0 as a placeholder.","Guard generators against defaulting lookups to 0."],"tags":["config","provider","validation"],"backgroundTag":"invalid-config-value","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"}