{"record":{"id":"9c3b64b5eab5ce0a","repo":"influxdata/influxdb","slug":"role-name-cannot-be-empty","errorCode":null,"errorMessage":"role name cannot be empty","messagePattern":"role name cannot be empty","errorType":"validation","errorClass":"NewRoleNameError","httpStatus":null,"severity":"error","filePath":"influxdb3_authz/src/role/role.rs","lineNumber":88,"sourceCode":"\n    pub fn as_str(&self) -> &str {\n        &self.0\n    }\n\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);","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_authz/src/role/role.rs#L70-L106","documentation":"NewRoleNameError::Empty is returned when validating a new role name that is an empty string. Role names must be non-empty, within ROLE_NAME_MAX_LENGTH, and contain only alphanumeric characters plus the allowed separator set.","triggerScenarios":"Calling the role-creation API (new role name construction in influxdb3_authz/src/role/role.rs) with an empty name string.","commonSituations":"An empty role-name field in an API request body or CLI flag; a config/templating variable that expanded to nothing; trimming that reduced a whitespace-only name to \"\".","solutions":["Provide a non-empty role name in the creation request.","Validate before submission: check !name.is_empty() (and length/charset rules) client-side.","Fix the template/config/trimming logic that produced the empty value."],"exampleFix":"// before\nlet name = \"\"; // empty\nlet role = RoleName::new(name)?;\n// after\nlet name = \"engineering-writers\";\nlet role = RoleName::new(name)?;","handlingStrategy":"validation","validationCode":"fn validate_role_name(name: &str, max: usize) -> Result<(), NewRoleNameError> {\n    if name.is_empty() { return Err(NewRoleNameError::Empty); }\n    if name.len() > max { return Err(NewRoleNameError::TooLong); }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":"match RoleName::new(&input) {\n    Ok(name) => /* ... */,\n    Err(NewRoleNameError::Empty) => bail!(\"role name is required\"),\n    Err(e) => bail!(\"invalid role name: {e}\"),\n}","preventionTips":["Reject empty/whitespace-only role names in API request validation","Apply the same trimming and charset rules client-side before submitting","Ensure config templates always supply a default role name"],"tags":["authz","roles","validation"],"backgroundTag":"empty-required-field","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"}