{"record":{"id":"13d8398f201b5b34","repo":"influxdata/influxdb","slug":"role-name-contains-invalid-characters-only-alphanumeric-and","errorCode":null,"errorMessage":"role name contains invalid characters: only alphanumeric and [{0}] are allowed","messagePattern":"role name contains invalid characters: only alphanumeric and \\[(.+?)\\] are allowed","errorType":"validation","errorClass":"NewRoleNameError","httpStatus":null,"severity":"error","filePath":"influxdb3_authz/src/role/role.rs","lineNumber":92,"sourceCode":"\n    pub fn into_inner(self) -> String {\n        self.0\n    }\n}\n\nimpl std::fmt::Display for RoleName {\n    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {\n        write!(f, \"{}\", self.0)\n    }\n}\n\n#[derive(Debug, Clone, Error)]\npub enum NewRoleNameError {\n    #[error(\"role name cannot be empty\")]\n    Empty,\n    #[error(\"role name exceeds maximum length of {ROLE_NAME_MAX_LENGTH} characters\")]\n    TooLong,\n    #[error(\"role name contains invalid characters: only alphanumeric and [{0}] are allowed\")]\n    InvalidCharacters(String),\n}\n\n#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]\npub struct RoleDescription(String);\n\nimpl RoleDescription {\n    pub fn as_str(&self) -> &str {\n        &self.0\n    }\n\n    pub fn new(description: &str) -> Result<Self, NewRoleDescriptionError> {\n        if description.is_empty() {\n            return Err(NewRoleDescriptionError::Empty);\n        }\n\n        if description.len() > ROLE_DESCRIPTION_MAX_LENGTH {\n            return Err(NewRoleDescriptionError::TooLong);","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_authz/src/role/role.rs#L74-L110","documentation":"NewRoleNameError::InvalidCharacters is returned when a role name contains characters outside the allowed set: alphanumeric characters plus the characters listed in the error's payload (formatted by format_allowed_chars). The library rejects such names to keep role identifiers safe in URLs and identifiers.","triggerScenarios":"Passing a role name containing spaces, symbols (e.g. '/', '@', ':'), or non-ASCII characters to role creation or renaming APIs.","commonSituations":"Deriving role names from user emails, URLs, or display labels ('Platform Eng admins') that contain spaces or punctuation.","solutions":["Sanitize the name to only alphanumeric characters (and the allowed punctuation listed in the error message, typically '-' and '_')","Replace disallowed characters with '-' or '_' before submitting","Add client-side validation with a regex like ^[a-zA-Z0-9_-]+$ before calling the API"],"exampleFix":"// before\nlet name = \"platform/eng admin\";\n// after\nlet name = \"platform-eng-admin\"; // or sanitize: input.chars().map(|c| if c.is_ascii_alphanumeric() || ALLOWED.contains(&c) { c } else { '-' }).collect()","handlingStrategy":"validation","validationCode":"fn valid_role_name_chars(name: &str) -> bool {\n    // allowed extras (e.g. '-' and '_') come from format_allowed_chars in role.rs\n    name.chars().all(|c| c.is_ascii_alphanumeric() || c == '-' || c == '_')\n}","typeGuard":"fn sanitize_role_name(raw: &str) -> String {\n    raw.chars().map(|c| if c.is_ascii_alphanumeric() || c == '-' || c == '_' { c } else { '-' }).collect()\n}","tryCatchPattern":null,"preventionTips":["Enforce an ^[A-Za-z0-9_-]+$ regex on role names in clients","Never derive role names directly from emails, URLs, or free-text labels without sanitizing","Document the allowed character set for role naming in your team's conventions"],"tags":["validation","role-management","rust"],"backgroundTag":"invalid-identifier-format","analyzedSha":"06200ef96ba82c5f6727e5038a83af8e722c6875","analyzedAt":"2026-09-19T12:55:30.003Z","contentChangedAt":"2026-09-19T12:55:30.003Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}