apache/cassandra · error · InvalidRequestException
ALTER [ROLE|USER] can't be empty
Error message
ALTER [ROLE|USER] can't be empty
What it means
AlterRoleStatement.validate rejects an ALTER ROLE/USER statement that specifies nothing to change: no role options, no DC permissions change, and no CIDR permissions change. Such a statement is a no-op and is treated as invalid input.
Source
Thrown at src/java/org/apache/cassandra/cql3/statements/AlterRoleStatement.java:76
this(name, opts, null, null, false);
}
public AlterRoleStatement(RoleName name, RoleOptions opts, DCPermissions dcPermissions,
CIDRPermissions cidrPermissions, boolean ifExists)
{
this.role = RoleResource.role(name.getName());
this.opts = opts;
this.dcPermissions = dcPermissions;
this.cidrPermissions = cidrPermissions;
this.ifExists = ifExists;
}
public void validate(ClientState state) throws RequestValidationException
{
opts.validate();
if (opts.isEmpty() && dcPermissions == null && cidrPermissions == null)
throw new InvalidRequestException("ALTER [ROLE|USER] can't be empty");
if (dcPermissions != null)
{
dcPermissions.validate();
}
if (cidrPermissions != null)
{
// Ensure input CIDR group names are valid, i.e, existing in CIDR groups mapping table
cidrPermissions.validate();
}
// validate login here before authorize, to avoid leaking user existence to anonymous users.
state.ensureNotAnonymous();
if (!DatabaseDescriptor.getRoleManager().isExistingRole(role))
{
checkTrue(ifExists, "Role %s doesn't exist", role.getRoleName());
}View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Add at least one option, e.g. WITH PASSWORD = '...', WITH LOGIN = true, or SUPERUSER = false
- Add a DC ACCESS or CIDR permissions clause if that is the intended change
- Remove the statement entirely if no change was intended
Example fix
// before ALTER ROLE app_role; // after ALTER ROLE app_role WITH LOGIN = true;
Defensive patterns
Strategy: validation
Validate before calling
// ensure the ALTER has at least one change before executing
boolean hasChange = !options.isEmpty() || dcPermissions != null || cidrPermissions != null;
if (!hasChange) throw new IllegalArgumentException("ALTER ROLE needs at least one option, DC permission, or CIDR permission"); Try / catch
try { session.execute(alterRoleCql); } catch (InvalidRequestException e) { if (e.getMessage().contains("can't be empty")) { /* skip no-op or add options */ } else throw e; } Prevention
- Build ALTER statements programmatically only when at least one option is set
- Skip generating the statement entirely when the change set is empty
- Lint generated CQL for bare 'ALTER ROLE x;' statements
When it happens
Trigger: ALTER ROLE some_role; or ALTER USER alice; with no WITH option clause and no dcPermissions/cidrPermissions clause, after opts.validate() passes.
Common situations: Programmatically generated ALTER statements where all option fields were empty; partial template rendering that dropped the options; fat-fingered statements with only the role name.
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
- Multiple definition for property '%s'
- You aren't allowed to alter %s
- Role name can't be an empty string
- %s already exists
- Only superusers can drop a role with superuser status
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/0e16efff68491a42.
Report an issue: GitHub.