BigPizzaV3/CodexPlusPlus · error
上下文 id 不能为空
Error message
上下文 id 不能为空
What it means
upsert_context_entry_in_common_config inserts an entry under an [table] section of the common config.toml; the entry id is trimmed and must be non-empty because it becomes a TOML key. Empty ids would produce invalid or meaningless entries, so they are rejected first.
Solutions
- Provide a non-empty id (the TOML key for the entry) before calling
- Validate the id field in the caller/UI prior to invoking this function
- Generate a default id from other fields if the user leaves it blank
Example fix
// before
upsert_context_entry_in_common_config("mcp_servers", " ", body, config)?;
// after
upsert_context_entry_in_common_config("mcp_servers", "my-server", body, config)?; Defensive patterns
Strategy: validation
Validate before calling
if id.trim().is_empty() {
return Err(anyhow::anyhow!("上下文 id 不能为空"));
} Try / catch
match upsert_context_entry_in_common_config(kind, &id, &body, config) {
Err(e) if e.to_string().contains("上下文 id 不能为空") => request_entry_name_from_user(),
other => other?,
} Prevention
- Make the id field required in the entry form
- Auto-derive an id slug from the entry's name/command if blank
- Reject whitespace-only ids at the UI layer
When it happens
Trigger: Calling upsert_context_entry_in_common_config(kind, id, toml_body, common_config) with id == "" or whitespace.
Common situations: A UI form where the context/profile name field was left blank; programmatic callers building entries from data where the identifier field was missing.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/42449e084ddae4e9.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/relay_config.rs:1039
) -> anyhow::Result<CodexContextEntries> {
let normalized = normalize_duplicate_toml_text(common_config);
let doc = parse_toml_document(&normalized)?;
Ok(CodexContextEntries {
mcp_servers: list_context_entries_for_table(&doc, "mcp_servers"),
skills: list_context_entries_for_table(&doc, "skills"),
plugins: list_context_entries_for_table(&doc, "plugins"),
})
}
pub fn upsert_context_entry_in_common_config(
common_config: &str,
kind: &str,
id: &str,
toml_body: &str,
) -> anyhow::Result<String> {
let id = id.trim();
if id.is_empty() {
anyhow::bail!("上下文 id 不能为空");
}
let table_name = context_table_name(kind)?;
let body_doc = parse_toml_document(toml_body)?;
let normalized = normalize_duplicate_toml_text(common_config);
let mut doc = parse_toml_document(&normalized)?;
if !doc.as_table().contains_key(table_name) {
doc[table_name] = toml_edit::table();
}
if doc[table_name].as_table().is_none() {
anyhow::bail!("{table_name} 必须是 TOML 表");
}
doc[table_name][id] = Item::Table(body_doc.as_table().clone());
Ok(normalize_optional_toml(doc))
}
pub fn delete_context_entry_from_common_config(
common_config: &str,
kind: &str,View on GitHub (pinned to b1ed92e5e4)