{"record":{"id":"f7eec6147f06d0aa","repo":"gleam-lang/gleam","slug":"failed-regex-to-match-valid-name-format","errorCode":null,"errorMessage":"failed regex to match valid name format","messagePattern":"failed regex to match valid name format","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler-cli/src/new.rs","lineNumber":364,"sourceCode":"            reason: InvalidProjectNameReason::ErlangReservedWord,\n        })\n    } else if erlang::is_erlang_standard_library_module(name) {\n        Err(Error::InvalidProjectName {\n            name: name.to_string(),\n            reason: InvalidProjectNameReason::ErlangStandardLibraryModule,\n        })\n    } else if parse::lexer::string_to_keyword(name).is_some() {\n        Err(Error::InvalidProjectName {\n            name: name.to_string(),\n            reason: InvalidProjectNameReason::GleamReservedWord,\n        })\n    } else if name == \"gleam\" {\n        Err(Error::InvalidProjectName {\n            name: name.to_string(),\n            reason: InvalidProjectNameReason::GleamReservedModule,\n        })\n    } else if regex::Regex::new(\"^[a-z][a-z0-9_]*$\")\n        .expect(\"failed regex to match valid name format\")\n        .is_match(name)\n    {\n        Ok(())\n    } else if regex::Regex::new(\"^[a-zA-Z][a-zA-Z0-9_]*$\")\n        .expect(\"failed regex to match valid but non-lowercase name format\")\n        .is_match(name)\n    {\n        Err(Error::InvalidProjectName {\n            name: name.to_string(),\n            reason: InvalidProjectNameReason::FormatNotLowercase,\n        })\n    } else {\n        Err(Error::InvalidProjectName {\n            name: name.to_string(),\n            reason: InvalidProjectNameReason::Format,\n        })\n    }\n}","sourceCodeStart":346,"sourceCodeEnd":382,"githubUrl":"https://github.com/gleam-lang/gleam/blob/15b07c783065c92bb016b1b74ed0995a5259850f/compiler-cli/src/new.rs#L346-L382","documentation":"In validate_name, the lowercase-name regex ^[a-z][a-z0-9_]*$ is compiled with .expect(\"failed regex to match valid name format\"). The pattern is a compile-time constant and always valid, so this panic is an internal invariant violation and can only fire if the regex crate itself rejects a known-good pattern (e.g. regex crate regression or size/feature issue).","triggerScenarios":"Calling validate_name (via suggest_valid_name or get_valid_project_name, e.g. `gleam new`) in a build where the regex engine cannot compile the fixed pattern — effectively never in a correct build.","commonSituations":"A broken or unusual regex crate build (feature flags, stack size limits in exotic targets), or tampered binaries; not a user-input problem — invalid names return Err(Error::InvalidProjectName) instead.","solutions":["Rebuild gleam / update to the latest release — the panic indicates a build or dependency issue, not your project name","Check the regex crate version in Cargo.lock and update it if a known regression exists","If you see this on a custom target, ensure adequate stack size for regex compilation","File a Gleam issue with your platform details"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"fn looks_like_valid_gleam_name(name: &str) -> bool {\n    !name.is_empty()\n        && name.chars().next().map_or(false, |c| c.is_ascii_lowercase())\n        && name.chars().all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_')\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate project names client-side before `gleam new`","Use lowercase letters, digits, underscores, starting with a letter","Update gleam/regex if this constant-pattern panic ever fires","Treat this panic as a bug report trigger, not a user error"],"tags":["regex","panic","internal","project-name"],"backgroundTag":"invalid-regex-pattern","analyzedSha":"15b07c783065c92bb016b1b74ed0995a5259850f","analyzedAt":"2026-09-14T11:14:59.388Z","contentChangedAt":"2026-09-14T11:14:59.388Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}