BigPizzaV3/CodexPlusPlus · error
未知上下文类型:
Error message
未知上下文类型:{other} What it means
context_table_name maps a context kind string ("mcp", "skill", "plugin", and plural variants) to its backing table name; any other kind is rejected with this error. It is an allowlist: only MCP servers, skills, and plugins are supported context types for this operation.
Solutions
- Use one of the supported kinds: "mcp", "skill", or "plugin" (or their plurals)
- Fix casing/typos — matching is exact ("mcpServer", not "MCP" or "mcpserver")
- If a new context type is genuinely needed, add it to the match in context_table_name
- Confirm you are calling the context API, not the config-file API, with this string
Example fix
// before
await listContext("tools")
// after
await listContext("plugins") Defensive patterns
Strategy: validation
Validate before calling
const KINDS = new Set(['mcp','mcpServer','mcpServers','skill','skills','plugin','plugins']);
if (!KINDS.has(kind)) throw new Error(`unsupported context kind: ${kind}`); Type guard
const isContextKind = (k) => ['mcp','mcpServer','mcpServers','skill','skills','plugin','plugins'].includes(k);
Try / catch
try { await listContext(kind); } catch (e) { if (String(e).includes('未知上下文类型')) { console.error(`Use mcp/skill/plugin, got: ${kind}`); } else throw e; } Prevention
- Keep a constant list of allowed context kinds in callers
- Normalize kind casing/singular-plural before calling
- Don't confuse context kinds with config file types (config/auth)
When it happens
Trigger: Calling the context-related command/lookup with kind values other than mcp/mcpServer/mcpServers/skill/skills/plugin/plugins — e.g. "extension", "tool", "agent", or an empty string. (Note: commands.rs:5821 has a similar error '未知配置文件类型' for config file types "config"/"auth"; do not confuse the two.)
Common situations: A UI or script passes a new/unfamiliar context category added by a newer Codex version that this build doesn't know; a typo like "mcpserver" or "Skill" (case-sensitive match); passing a config-file type where a context kind is expected.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- invalid user script key
- unsupported Dream Skin package image
- 主题包必须是 32 MiB 以内的普通 ZIP 文件
- 请填写 API 的模型名称
- 官方混合 API 不应在 auth.json 中保存 OPENAI_API_KEY。请清理此供应商的…
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/978d11e5f2724250.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/relay_config.rs:2643
toml_body: body,
enabled: context_entry_enabled(table),
})
})
.collect()
}
fn table_body_to_string(table: &Table) -> String {
let mut doc = DocumentMut::new();
merge_toml_table_like(doc.as_table_mut(), table);
normalize_optional_toml(doc)
}
fn context_table_name(kind: &str) -> anyhow::Result<&'static str> {
match kind {
"mcp" | "mcpServer" | "mcpServers" => Ok("mcp_servers"),
"skill" | "skills" => Ok("skills"),
"plugin" | "plugins" => Ok("plugins"),
other => anyhow::bail!("未知上下文类型:{other}"),
}
}
fn context_kind_name(table: &str) -> &'static str {
match table {
"mcp_servers" => "mcp",
"skills" => "skill",
"plugins" => "plugin",
_ => "unknown",
}
}
fn context_entry_summary(body: &str) -> String {
body.lines()
.map(str::trim)
.find(|line| !line.is_empty() && !line.starts_with('#'))
.unwrap_or("")
.chars()View on GitHub (pinned to b1ed92e5e4)