apache/cassandra · error · RuntimeException
Unable to serialize role_name_policy configuration
Error message
Unable to serialize role_name_policy configuration
What it means
Identical mechanism to the password_policy variant: serializing the role name policy configuration to JSON fails, and Guardrails.getRoleNamePolicy() throws RuntimeException('Unable to serialize role_name_policy configuration') with the underlying cause dropped.
Solutions
- Reproduce to expose the hidden Jackson cause (the message omits it); check server logs
- Reset role_name_policy to the default via the corresponding setter and retry
- Align Jackson versions / remove conflicting jackson-databind jars from the classpath
- Fix the config object's getters so JSON serialization succeeds
Example fix
// before RoleNamePolicyConfig with a getter that throws -> serialization fails // after Make all getters side-effect-free and Jackson-visible (public accessors, no throwing getters)
Defensive patterns
Strategy: try-catch
Validate before calling
// Round-trip check after setting the policy
String json = guardrails.getRoleNamePolicy();
if (json == null || json.isEmpty()) logger.warn("role_name_policy serialization returned empty"); Try / catch
try {
String json = guardrails.getRoleNamePolicy();
} catch (RuntimeException e) {
if (e.getMessage().contains("role_name_policy")) {
logger.error("Role name policy not serializable; resetting", e);
guardrails.setRoleNamePolicy(defaultJson);
}
} Prevention
- Validate JSON policy input before calling the setter
- Avoid custom config classes with throwing or inaccessible getters
- Keep classpath clean of mismatched jackson-databind versions
When it happens
Trigger: Calling getRoleNamePolicy() after the role name policy config object became non-serializable by Jackson (bad object set via setRoleNamePolicy, missing accessors, Jackson version conflict).
Common situations: Programmatic administration tools reading back a recently changed role_name_policy; mixed Jackson versions on the classpath; a policy object with throwing getters.
Understand the failure class
Background: "JSON serialization failed", "not JSON serializable", "Failed to serialize": why JSON marshaling errors happen and how to fix them — this error's family across 46 libraries.
Related errors
- Unable to serialize minimum_client_driver_versions_warned…
- Unable to serialize…
- Unable to serialize password_policy configuration
- Batch too large
- Cannot alter gc_grace_seconds of a materialized view to 0…
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/2b3b317e252f329d.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/db/guardrails/Guardrails.java:1600
{
return JsonUtils.JSON_OBJECT_MAPPER.writeValueAsString(passwordPolicy.getConfig());
}
catch (Throwable t)
{
throw new RuntimeException("Unable to serialize password_policy configuration");
}
}
@Override
public String getRoleNamePolicy()
{
try
{
return JsonUtils.JSON_OBJECT_MAPPER.writeValueAsString(roleNamePolicy.getConfig());
}
catch (Throwable t)
{
throw new RuntimeException("Unable to serialize role_name_policy configuration");
}
}
@Override
public void setPasswordPolicy(String value)
{
try
{
passwordPolicy.reconfigure(JsonUtils.JSON_OBJECT_MAPPER.readValue(value, new TypeReference<>() {}));
}
catch (Throwable t)
{
throw new RuntimeException(t);
}
}
@Override
public void setRoleNamePolicy(String value)View on GitHub (pinned to 88fd0f6a0e)