{"record":{"id":"32c177ff42450f60","repo":"BigPizzaV3/CodexPlusPlus","slug":"error-32c177","errorCode":null,"errorMessage":"供应商名称为空","messagePattern":"供应商名称为空","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/provider_import.rs","lineNumber":225,"sourceCode":"        vlm_api_key: String::new(),\n        vlm_model: String::new(),\n        vlm_base_url: String::new(),\n        user_agent: String::new(),\n        sub2api_enabled: false,\n        sub2api_multiplier: String::new(),\n        model_routes: Vec::new(),\n        standard_openai_protocol: false,\n    }\n}\n\nfn normalize_request(mut request: ProviderImportRequest) -> anyhow::Result<ProviderImportRequest> {\n    request.name = request.name.trim().to_string();\n    request.base_url = request.base_url.trim().trim_end_matches('/').to_string();\n    request.api_key = request.api_key.trim().to_string();\n    request.wire_api = request.wire_api.trim().to_ascii_lowercase();\n    request.relay_mode = request.relay_mode.trim().to_ascii_lowercase();\n    if request.name.is_empty() {\n        anyhow::bail!(\"供应商名称为空\");\n    }\n    if request.base_url.is_empty() {\n        anyhow::bail!(\"Base URL 为空\");\n    }\n    if request.api_key.is_empty() {\n        anyhow::bail!(\"API Key 为空\");\n    }\n    request.config_contents = build_config_toml(\n        &request.base_url,\n        &request.api_key,\n        relay_protocol(&request.wire_api),\n    );\n    request.auth_contents = build_auth_json(&request.api_key);\n    Ok(request)\n}\n\nfn relay_protocol(value: &str) -> RelayProtocol {\n    match value.trim().to_ascii_lowercase().as_str() {","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/provider_import.rs#L207-L243","documentation":"This error is thrown by `normalize_request` in provider_import.rs when importing a provider whose `name` field is empty or whitespace-only after trimming. The library requires every imported provider to have a non-empty display name because the name identifies the provider entry in stored profiles and generated config. It is a fail-fast validation guard at the start of the import pipeline.","triggerScenarios":"Calling `import_provider_with_store` with a `ProviderImportRequest` whose `name` is `\"\"` or only whitespace (e.g. `\"   \"`), which normalize_request trims to empty before this bail fires at provider_import.rs:225.","commonSituations":"A UI or CLI form submitted without filling the provider name field; programmatic import building the request struct manually and forgetting `name`; deserializing a saved/import JSON where the name key was missing or blank.","solutions":["Set a non-empty `name` on the ProviderImportRequest before calling import_provider_with_store.","If the name comes from user input, trim it and show a form-level error when it is blank.","If importing from JSON, validate the name field exists and is non-blank before deserializing into the request."],"exampleFix":"// before\nlet req = ProviderImportRequest { name: \"\".into(), base_url, api_key, ..Default::default() };\n// after\nlet req = ProviderImportRequest { name: \"My Relay\".into(), base_url, api_key, ..Default::default() };","handlingStrategy":"validation","validationCode":"let name = request.name.trim();\nif name.is_empty() {\n    return Err(anyhow::anyhow!(\"供应商名称不能为空\"));\n}\nrequest.name = name.to_string();","typeGuard":"fn has_name(req: &ProviderImportRequest) -> bool { !req.name.trim().is_empty() }","tryCatchPattern":"match import_provider_with_store(&store, request) {\n    Ok(profile) => println!(\"imported {}\", profile.name),\n    Err(e) if e.to_string().contains(\"供应商名称为空\") => eprintln!(\"请填写供应商名称\"),\n    Err(e) => return Err(e),\n}","preventionTips":["Bind the import button to a form validation requiring a non-empty trimmed name.","Never construct ProviderImportRequest with Default::default() for name in code paths.","Validate JSON/import sources for the name field before deserialization."],"tags":["validation","provider-import","empty-field"],"backgroundTag":"empty-required-field","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"}