BigPizzaV3/CodexPlusPlus · error
Grok 模型别名重复:
Error message
Grok 模型别名重复:{alias} What it means
validate_request enforces that every model alias in a Grok save request is unique using a HashSet insert. If two entries in request.models share the same trimmed alias, this error aborts the whole save before any config is written, since duplicates would silently overwrite each other in the generated TOML.
Solutions
- De-duplicate request.models before saving (keep one entry per alias)
- Rename one of the conflicting models so each alias is unique
- If both entries are intended, confirm which one to keep and delete the other
Example fix
// before
models: [ {alias: "grok-4", ...}, {alias: "grok-4", ...} ]
// after
models: [ {alias: "grok-4", ...}, {alias: "grok-4-fast", ...} ] Defensive patterns
Strategy: validation
Validate before calling
let names: Vec<_> = request.models.iter().map(|m| m.alias.trim()).collect(); let uniq: HashSet<_> = names.iter().collect(); assert_eq!(names.len(), uniq.len());
Try / catch
match save_grok_config_at(...) { Err(e) if e.to_string().contains("别名重复") => { /* prompt user to rename */ } ... } Prevention
- De-duplicate model lists before constructing the request
- In UIs, warn immediately when a new row reuses an existing alias
- Use stable unique IDs in the UI keyed by row, not by alias
When it happens
Trigger: save_grok_config_at called where two or more entries in request.models have identical trimmed alias values (HashSet::insert returns false on the second insert).
Common situations: Duplicating a row in the manager UI's model list and forgetting to rename it; merging two config sources that both define grok-4; scripted batch imports appending an entry that already exists.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Grok 模型来源别名重复:
- 官方混合 API 不应在 auth.json 中保存 OPENAI_API_KEY。请清理此供应商的…
- 请填写 API 的模型名称
- Base URL 不能为空
- 上游 Base URL 不能为空
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/3b581129af2795bf.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/grok_config.rs:283
}
models.insert(alias, item);
}
Ok(())
}
fn validate_request(request: &SaveGrokConfigRequest) -> anyhow::Result<()> {
let mut aliases = HashSet::new();
let mut sources = HashSet::new();
for input in &request.models {
let alias = input.alias.trim();
if alias.is_empty() {
bail!("Grok 模型别名不能为空");
}
if alias.chars().any(char::is_control) {
bail!("Grok 模型别名不能包含控制字符");
}
if !aliases.insert(alias.to_string()) {
bail!("Grok 模型别名重复:{alias}");
}
let source = input.source_alias.trim();
if !source.is_empty() && !sources.insert(source.to_string()) {
bail!("Grok 模型来源别名重复:{source}");
}
if !matches!(
input.api_backend.trim(),
"responses" | "chat_completions" | "messages"
) {
bail!("Grok 模型 {alias} 的 API 协议无效");
}
if input.context_window == Some(0) {
bail!("Grok 模型 {alias} 的上下文窗口必须大于 0");
}
if input
.context_window
.is_some_and(|value| value > i64::MAX as u64)
{View on GitHub (pinned to b1ed92e5e4)