{"record":{"id":"aaa1fa0d5e30f60b","repo":"BigPizzaV3/CodexPlusPlus","slug":"grok-alias-0","errorCode":null,"errorMessage":"Grok 模型 {alias} 的上下文窗口必须大于 0","messagePattern":"Grok 模型 (.+?) 的上下文窗口必须大于 0","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/grok_config.rs","lineNumber":296,"sourceCode":"        }\n        if alias.chars().any(char::is_control) {\n            bail!(\"Grok 模型别名不能包含控制字符\");\n        }\n        if !aliases.insert(alias.to_string()) {\n            bail!(\"Grok 模型别名重复：{alias}\");\n        }\n        let source = input.source_alias.trim();\n        if !source.is_empty() && !sources.insert(source.to_string()) {\n            bail!(\"Grok 模型来源别名重复：{source}\");\n        }\n        if !matches!(\n            input.api_backend.trim(),\n            \"responses\" | \"chat_completions\" | \"messages\"\n        ) {\n            bail!(\"Grok 模型 {alias} 的 API 协议无效\");\n        }\n        if input.context_window == Some(0) {\n            bail!(\"Grok 模型 {alias} 的上下文窗口必须大于 0\");\n        }\n        if input\n            .context_window\n            .is_some_and(|value| value > i64::MAX as u64)\n        {\n            bail!(\"Grok 模型 {alias} 的上下文窗口过大\");\n        }\n        if input.remove_api_key && !input.api_key_update.is_empty() {\n            bail!(\"Grok 模型 {alias} 不能同时替换并移除 API Key\");\n        }\n    }\n    Ok(())\n}\n\nfn table_string(doc: &DocumentMut, table: &str, key: &str) -> String {\n    doc.get(table)\n        .and_then(Item::as_table_like)\n        .and_then(|values| values.get(key))","sourceCodeStart":278,"sourceCodeEnd":314,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/grok_config.rs#L278-L314","documentation":"When a Grok model entry specifies a context_window, it must be greater than 0. A value of exactly Some(0) is rejected because a zero-size context window is meaningless and would break request sizing logic downstream.","triggerScenarios":"save_grok_config_at called with input.context_window == Some(0) — typically a default-initialized struct, a UI bound to a numeric field starting at 0, or deserialization that turned an empty string into 0.","commonSituations":"Leaving a spinner/number input at its 0 default; template configs with placeholder 0 values meant to be filled in; forgetting that None (unset) is the correct way to express 'no limit'.","solutions":["Set context_window to a positive value appropriate for the model (e.g. 131072)","Omit the field entirely (None) if the model has no explicit window requirement","Fix UI/serialization defaults so unset maps to None, not Some(0)"],"exampleFix":"// before\ncontext_window: Some(0)\n// after\ncontext_window: Some(131072)","handlingStrategy":"validation","validationCode":"if let Some(w) = req.context_window { assert!(w > 0, \"context_window must be > 0\"); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default unset windows to None, never Some(0)","Initialize numeric inputs with a sane positive default","Reject 0 at the form layer with a helpful message"],"tags":["validation","config","range"],"backgroundTag":"value-out-of-range","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}