{"record":{"id":"7caf33c743282701","repo":"gleam-lang/gleam","slug":"failed-regex-to-match-any-non-lowercase-and-non-al","errorCode":null,"errorMessage":"failed regex to match any non-lowercase and non-alphanumeric characters","messagePattern":"failed regex to match any non-lowercase and non-alphanumeric characters","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler-cli/src/new.rs","lineNumber":411,"sourceCode":"            }\n            _ => None,\n        },\n        InvalidProjectNameReason::ErlangReservedWord => Some(format!(\"{invalid_name}_app\")),\n        InvalidProjectNameReason::ErlangStandardLibraryModule => {\n            Some(format!(\"{invalid_name}_app\"))\n        }\n        InvalidProjectNameReason::GleamReservedWord => Some(format!(\"{invalid_name}_app\")),\n        InvalidProjectNameReason::GleamReservedModule => {\n            if invalid_name == \"gleam\" {\n                Some(\"app_gleam\".into())\n            } else {\n                Some(format!(\"{invalid_name}_app\"))\n            }\n        }\n        InvalidProjectNameReason::FormatNotLowercase => Some(invalid_name.to_lowercase()),\n        InvalidProjectNameReason::Format => {\n            let suggestion = regex::Regex::new(r\"[^a-z0-9]\")\n                .expect(\"failed regex to match any non-lowercase and non-alphanumeric characters\")\n                .replace_all(&invalid_name.to_lowercase(), \"_\")\n                .to_string();\n\n            let suggestion = regex::Regex::new(r\"_+\")\n                .expect(\"failed regex to match consecutive underscores\")\n                .replace_all(&suggestion, \"_\")\n                .to_string();\n\n            match validate_name(&suggestion) {\n                Ok(_) => Some(suggestion),\n                Err(_) => None,\n            }\n        }\n    }\n}\n\nfn get_valid_project_name(\n    provided_name: Option<&str>,","sourceCodeStart":393,"sourceCodeEnd":429,"githubUrl":"https://github.com/gleam-lang/gleam/blob/15b07c783065c92bb016b1b74ed0995a5259850f/compiler-cli/src/new.rs#L393-L429","documentation":"In suggest_valid_name (InvalidProjectNameReason::Format branch), the regex [^a-z0-9] used to replace invalid characters with underscores is compiled with an .expect panic. Like the other new.rs regexes, the constant pattern is always valid, so this panic signals a regex-engine internal failure rather than bad input.","triggerScenarios":"`gleam new` with a name that has invalid format, triggering the suggestion path, in a build where the regex crate cannot compile the fixed pattern — normally unreachable.","commonSituations":"Broken dependency builds, unusual targets, or binary corruption. Users with invalid names should otherwise receive a suggestion or a normal InvalidProjectName error.","solutions":["Rebuild/update gleam — this is a build/dependency problem, not a naming problem","Update the regex crate in Cargo.lock if a regression exists","Report to Gleam maintainers with platform details if reproducible"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"fn suggestion_charset_ok(s: &str) -> bool {\n    s.chars().all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_')\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use names matching [a-z][a-z0-9_]* from the start","Avoid symbols/unicode in project names","Rebuild if constant regexes panic","Sanitize names in scripts that call gleam new"],"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"}