{"record":{"id":"1c51fce957320795","repo":"BigPizzaV3/CodexPlusPlus","slug":"label-0","errorCode":null,"errorMessage":"{label}必须大于 0","messagePattern":"(.+?)必须大于 0","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/relay_config.rs","lineNumber":1922,"sourceCode":"fn validate_auth_json(auth_bytes: &[u8], path: &Path) -> anyhow::Result<()> {\n    if auth_bytes.iter().all(|byte| byte.is_ascii_whitespace()) {\n        return Ok(());\n    }\n    serde_json::from_slice::<Value>(auth_bytes)\n        .with_context(|| format!(\"{} 不是有效 JSON\", path.display()))?;\n    Ok(())\n}\n\nfn parse_optional_positive_u64(value: &str, label: &str) -> anyhow::Result<Option<u64>> {\n    let trimmed = value.trim();\n    if trimmed.is_empty() {\n        return Ok(None);\n    }\n    let parsed = trimmed\n        .parse::<u64>()\n        .with_context(|| format!(\"{label}必须是正整数\"))?;\n    if parsed == 0 {\n        anyhow::bail!(\"{label}必须大于 0\");\n    }\n    Ok(Some(parsed))\n}\n\nfn apply_context_limits_to_config(\n    config_text: &str,\n    context_window: &str,\n    auto_compact_limit: &str,\n) -> anyhow::Result<String> {\n    let mut doc = parse_toml_document(config_text)?;\n    if let Some(value) = parse_optional_positive_u64(context_window, \"上下文大小\")? {\n        doc[\"model_context_window\"] = toml_edit::value(value as i64);\n    }\n    if let Some(value) = parse_optional_positive_u64(auto_compact_limit, \"压缩上下文大小\")? {\n        doc[\"model_auto_compact_token_limit\"] = toml_edit::value(value as i64);\n    }\n    Ok(normalize_optional_toml(doc))\n}","sourceCodeStart":1904,"sourceCodeEnd":1940,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/relay_config.rs#L1904-L1940","documentation":"parse of a numeric limit field (context window / auto-compact threshold) requires a positive integer. A value of 0 parses as u64 but is rejected with '{label}必须大于 0' because a zero context window or compact threshold is meaningless. Non-numeric input fails earlier with '{label}必须是正整数'.","triggerScenarios":"Calling the limit-parsing helper (used by apply_context_limits_to_config) with a string like \"0\" or \"+0\" for a context-window or auto-compact limit.","commonSituations":"User typed 0 in the per-model context window field intending 'unlimited'; a template exported 0 as a placeholder and it was applied verbatim.","solutions":["Use a positive integer (e.g. \"128000\") for the limit","To express 'no limit / unset', remove the field or pass None/empty so the helper returns Ok(None) instead of 0","Update UI validation to reject 0 at input time"],"exampleFix":"// before\nmodel_windows.insert(\"deepseek-v4-pro\".into(), \"0\".into());\n// after\nmodel_windows.insert(\"deepseek-v4-pro\".into(), \"1000000\".into());","handlingStrategy":"validation","validationCode":"fn valid_limit(v: &str) -> bool {\n    v.trim().parse::<u64>().map(|n| n > 0).unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":"match apply_limits(text, limits) {\n    Err(e) if e.to_string().contains(\"必须大于 0\") => clear_or_unset_limit_field(e)?,\n    other => other?,\n}","preventionTips":["Reject 0 in window/threshold input fields (treat blank as unset)","Constrain inputs to positive integers with min=1","Document that 'unset' is expressed by omitting the field, not 0"],"tags":["validation","numeric","value-out-of-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"}