{"record":{"id":"5cd326286f52f30a","repo":"BigPizzaV3/CodexPlusPlus","slug":"config-toml","errorCode":null,"errorMessage":"config.toml 内容不能为空","messagePattern":"config\\.toml 内容不能为空","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/relay_config.rs","lineNumber":326,"sourceCode":"    )\n}\n\npub fn apply_relay_files_to_home(\n    home: &Path,\n    config_contents: &str,\n    auth_contents: &str,\n) -> anyhow::Result<RelayApplyResult> {\n    apply_relay_files_to_home_with_computer_use_guard(home, config_contents, auth_contents, false)\n}\n\npub fn apply_relay_files_to_home_with_computer_use_guard(\n    home: &Path,\n    config_contents: &str,\n    auth_contents: &str,\n    preserve_computer_use_guard: bool,\n) -> anyhow::Result<RelayApplyResult> {\n    if config_contents.trim().is_empty() {\n        anyhow::bail!(\"config.toml 内容不能为空\");\n    }\n    std::fs::create_dir_all(home)?;\n\n    let backup_path = write_codex_live_atomic(\n        home,\n        Some(config_contents),\n        Some(auth_contents.as_bytes()),\n        preserve_computer_use_guard,\n    )?;\n\n    let status = relay_config_status_from_home(home);\n    Ok(RelayApplyResult {\n        config_path: status.config_path,\n        backup_path,\n        configured: status.configured,\n    })\n}\n","sourceCodeStart":308,"sourceCodeEnd":344,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/1f431ae49b57b3055e0e6845ba6156c6b4232b4d/crates/codex-plus-core/src/relay_config.rs#L308-L344","documentation":"apply_relay_files_to_home_with_computer_use_guard 在把传入的 config.toml 内容原子写入 Codex home 之前，要求 config_contents trim 后非空。为空则 bail，不创建目录、不写文件、不产生备份。这是按「整份文件内容」应用中转配置的通用入口（computer_use_guard 变体控制是否保留实验性守护配置）。","triggerScenarios":"调用 apply_relay_files_to_home* 系列函数（含 with_computer_use_guard 变体）时 config_contents 参数是空字符串或纯空白（空格/换行/BOM 之后的空白也不行——注意本函数不做 BOM 剥离，但 trim 会忽略 BOM 之外的空白）。auth_contents 为空不会触发本错误，只有 config_contents 会。","commonSituations":"前端编辑器内容未加载完成就提交；从 profile 读取 config_contents 时字段为空；上游生成的 config 文本为空串；误以为传空 config 可以只更新 auth.json。","solutions":["调用前检查 config_contents.trim() 非空","若只想更新 auth.json，使用 clear/write 系列的其他接口而非本函数","检查 profile.config_contents 是否在保存/切换流程中被意外清空"],"exampleFix":"// before\nlet r = apply_relay_files_to_home(&home, \"\", &auth)?;\n\n// after\nlet cfg = config_contents.trim();\nif cfg.is_empty() {\n    return Err(anyhow::anyhow!(\"config.toml 内容不能为空\"));\n}\nlet r = apply_relay_files_to_home(&home, cfg, &auth)?;","handlingStrategy":"validation","validationCode":"anyhow::ensure!(!config_contents.trim().is_empty(), \"config.toml 内容不能为空\");\napply_relay_files_to_home_with_computer_use_guard(&home, config_contents, auth_contents, preserve)?;","typeGuard":null,"tryCatchPattern":"if let Err(err) = apply_relay_files_to_home_with_computer_use_guard(&home, cfg, auth, keep) {\n    if err.to_string().contains(\"config.toml 内容不能为空\") {\n        // 视为用户输入问题：提示编辑器内容为空，不要重试\n    } else { return Err(err); }\n}","preventionTips":["文件读取失败时返回错误而不是空串兜底","编辑器保存流程里对空内容做前置校验","只想更新 auth.json 时不要调用会写 config 的接口"],"tags":["config-toml","validation","codex-plus-core"],"backgroundTag":"empty-required-field","analyzedSha":"1f431ae49b57b3055e0e6845ba6156c6b4232b4d","analyzedAt":"2026-08-16T20:54:18.598Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}