influxdata/influxdb · error · NewRoleNameError
role name cannot be empty
Error message
role name cannot be empty
What it means
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.
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.
Example fix
// before let name = ""; // empty let role = RoleName::new(name)?; // after let name = "engineering-writers"; let role = RoleName::new(name)?;
Defensive patterns
Strategy: validation
Validate before calling
fn validate_role_name(name: &str, max: usize) -> Result<(), NewRoleNameError> {
if name.is_empty() { return Err(NewRoleNameError::Empty); }
if name.len() > max { return Err(NewRoleNameError::TooLong); }
Ok(())
} Try / catch
match RoleName::new(&input) {
Ok(name) => /* ... */,
Err(NewRoleNameError::Empty) => bail!("role name is required"),
Err(e) => bail!("invalid role name: {e}"),
} Prevention
- 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
When it happens
Trigger: Calling the role-creation API (new role name construction in influxdb3_authz/src/role/role.rs) with an empty name string.
Common situations: 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 "".
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- invalid resource name
- missing resource id
- missing resource name
- unknown system resource identifier
- action not supported
AI-assisted analysis of influxdata/influxdb@06200ef96b (2026-09-19).
Data as JSON: /api/errors/9c3b64b5eab5ce0a.
Report an issue: GitHub.
Appendix: source
Thrown at influxdb3_authz/src/role/role.rs:88
pub fn as_str(&self) -> &str {
&self.0
}
pub fn into_inner(self) -> String {
self.0
}
}
impl std::fmt::Display for RoleName {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
#[derive(Debug, Clone, Error)]
pub enum NewRoleNameError {
#[error("role name cannot be empty")]
Empty,
#[error("role name exceeds maximum length of {ROLE_NAME_MAX_LENGTH} characters")]
TooLong,
#[error("role name contains invalid characters: only alphanumeric and [{0}] are allowed")]
InvalidCharacters(String),
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct RoleDescription(String);
impl RoleDescription {
pub fn as_str(&self) -> &str {
&self.0
}
pub fn new(description: &str) -> Result<Self, NewRoleDescriptionError> {
if description.is_empty() {
return Err(NewRoleDescriptionError::Empty);View on GitHub (pinned to 06200ef96b)