{"record":{"id":"9b0bc7ceb72c1ea9","repo":"openai/codex","slug":"field-field-name-cannot-be-empty","errorCode":null,"errorMessage":"field `{field_name}` cannot be empty","messagePattern":"field `(.+?)` cannot be empty","errorType":"validation","errorClass":"ConstraintError","httpStatus":null,"severity":"error","filePath":"codex-rs/config/src/constraint.rs","lineNumber":22,"sourceCode":"use crate::config_requirements::RequirementSource;\nuse thiserror::Error;\n\n#[derive(Debug, Error, PartialEq, Eq)]\npub enum ConstraintError {\n    #[error(\n        \"invalid value for `{field_name}`: `{candidate}` is not in the allowed set {allowed} (set by {requirement_source})\"\n    )]\n    InvalidValue {\n        field_name: &'static str,\n        candidate: String,\n        allowed: String,\n        requirement_source: RequirementSource,\n    },\n\n    #[error(\"To use model `{model}`, you need to use auto review.\")]\n    AutoReviewRequired { model: String },\n\n    #[error(\"field `{field_name}` cannot be empty\")]\n    EmptyField { field_name: String },\n\n    #[error(\"invalid rules in requirements (set by {requirement_source}): {reason}\")]\n    ExecPolicyParse {\n        requirement_source: RequirementSource,\n        reason: String,\n    },\n\n    #[error(\n        \"invalid requirement for MCP server `{server_name}` (set by {requirement_source}): {reason}\"\n    )]\n    McpServerRequirementParse {\n        server_name: String,\n        requirement_source: RequirementSource,\n        reason: String,\n    },\n}\n","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/config/src/constraint.rs#L4-L40","documentation":"ConstraintError::EmptyField (codex-rs/config/src/constraint.rs:22, built via ConstraintError::empty_field) is returned by a Constrained validator when a field that must be non-empty receives an empty string. field_name in the message identifies exactly which field failed.","triggerScenarios":"Setting a constrained non-empty string field (a name or identifier in config or requirements) to an empty string via config.toml, an override, or an API set call; the validator does not trim, so empty and whitespace-only values fail.","commonSituations":"Template configs generated with empty placeholders (name = \"\"); env-var-driven overrides that expand to an empty string; scripts writing config keys unconditionally even when the source value is missing.","solutions":["Give the field a non-empty value","Remove the key entirely instead of setting it to an empty string","If the value comes from an env var, default it or skip writing the key when the variable is empty"],"exampleFix":"# before\nname = \"\"\n\n# after\nname = \"my-server\"","handlingStrategy":"validation","validationCode":"fn non_empty(field: &str) -> Result<&str, String> {\n    let t = field.trim();\n    if t.is_empty() {\n        Err(\"field cannot be empty\".into())\n    } else {\n        Ok(t)\n    }\n}","typeGuard":"fn is_non_empty(s: &str) -> bool {\n    !s.trim().is_empty()\n}","tryCatchPattern":"match constrained.set(value) {\n    Err(ConstraintError::EmptyField { field_name }) => {\n        eprintln!(\"{field_name} must not be empty\");\n    }\n    r => r?,\n}","preventionTips":["Trim and reject empty inputs at the form or API boundary before they reach config","Omit keys rather than writing them as empty strings in generated configs","Unit-test config writers against empty env vars"],"tags":["config","validation","empty-string","constraints","rust"],"backgroundTag":"empty-required-field","analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}