{"record":{"id":"48d9daf0c91d040f","repo":"BigPizzaV3/CodexPlusPlus","slug":"timeout","errorCode":null,"errorMessage":"启动超时必须是正数：{timeout}","messagePattern":"启动超时必须是正数：(.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/mcp_config.rs","lineNumber":217,"sourceCode":"                table[\"args\"] = Item::Value(TomlValue::Array(array));\n            }\n            set_string(table, \"cwd\", &form.cwd);\n            set_inline_map(table, \"env\", &form.env);\n        }\n        McpTransport::Http => {\n            set_string(table, \"url\", &form.url);\n            set_inline_map(table, \"http_headers\", &form.http_headers);\n            set_string(table, \"bearer_token\", &form.bearer_token);\n        }\n    }\n\n    let timeout = form.startup_timeout_sec.trim();\n    if !timeout.is_empty() {\n        let parsed: f64 = timeout\n            .parse()\n            .with_context(|| format!(\"启动超时必须是数字：{timeout}\"))?;\n        if !parsed.is_finite() || parsed <= 0.0 {\n            anyhow::bail!(\"启动超时必须是正数：{timeout}\");\n        }\n        // 整数写成整数：toml_edit::value(30.0) 会产出 `30.0`，\n        // 而 codex 那边期望 f64，两种都收，但配置文件里 `30` 更干净。\n        if parsed.fract() == 0.0 && parsed.abs() < 1e15 {\n            table[\"startup_timeout_sec\"] = toml_edit::value(parsed as i64);\n        } else {\n            table[\"startup_timeout_sec\"] = toml_edit::value(parsed);\n        }\n    }\n\n    // enabled = true 是默认值，不写进去省得每条都带一行噪音\n    if !form.enabled {\n        table[\"enabled\"] = toml_edit::value(false);\n    }\n\n    if !form.extra_toml.trim().is_empty() {\n        let extra: DocumentMut = form\n            .extra_toml","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/mcp_config.rs#L199-L235","documentation":"build_mcp_toml_body validates the MCP form's startup_timeout_sec field. If the field is non-empty, it is parsed as f64; if the value parses but is zero, negative, NaN or infinite, this bail fires. The library requires startup timeout to be a strictly positive finite number because it is written verbatim into the codex config.toml and a non-positive timeout would be rejected or misbehave at runtime.","triggerScenarios":"Calling build_mcp_toml_body (directly or via parse_mcp_servers_json) with a form whose startup_timeout_sec is e.g. \"0\", \"-5\", \"0.0\", or a value that parses to NaN/inf (the parse itself failing produces the separate '必须是数字' error).","commonSituations":"User types 0 or a negative number into the startup-timeout field of the MCP config UI; JSON import carries startup_timeout_sec: 0 copied from another tool; locale/formatter output like \"1,5\" would hit the sibling numeric error, but \"-1\" hits this one.","solutions":["Set startup_timeout_sec to a positive number greater than 0 (e.g. 30).","If the timeout is unknown, leave the field empty/omitted so the default is used instead of 0.","Trim whitespace and ensure no sign character or scientific notation that evaluates to <= 0 is present.","If importing JSON, fix the offending server's startup_timeout_sec before import, or accept the per-entry warning and correct it afterwards."],"exampleFix":"// before\nstartup_timeout_sec = 0\n// after\nstartup_timeout_sec = 30","handlingStrategy":"validation","validationCode":"fn valid_timeout(s: &str) -> bool {\n    match s.trim().parse::<f64>() {\n        Ok(v) => v.is_finite() && v > 0.0,\n        Err(_) => false,\n    }\n}","typeGuard":null,"tryCatchPattern":"match build_mcp_toml_body(&form) {\n    Ok(body) => /* ... */,\n    Err(e) if e.to_string().contains(\"启动超时\") => show_field_error(\"startup_timeout_sec\", format!(\"{e}\")),\n    Err(e) => return Err(e),\n}","preventionTips":["Clamp the UI input to a positive numeric range before submission","Leave the field empty instead of entering 0 when no custom timeout is wanted","Validate numeric fields on blur, not only on save","Trim input and reject sign characters unless followed by a positive value"],"tags":["validation","mcp","config","numeric"],"backgroundTag":"invalid-config-value","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"}