apache/cassandra · error · RuntimeException
Unable to serialize password_policy configuration
Error message
Unable to serialize password_policy configuration
What it means
Guardrails.getPasswordPolicyConfig (part of the Guardrails public API) serializes the password policy configuration object to JSON using JsonUtils.JSON_OBJECT_MAPPER. Any Throwable during serialization is swallowed and replaced by a RuntimeException('Unable to serialize password_policy configuration') — the original cause is discarded.
Solutions
- Check the server log around the failure for the underlying Jackson error — this wrapper discards the cause, so reproduce with the same config to see it
- Reset the password policy to a known-good value (default config) via setPasswordPolicy, then retry
- Verify the Cassandra and Jackson versions are consistent (shaded jars / classpath pollution of a different jackson-databind)
- Inspect what was passed to setPasswordPolicy most recently; fix or remove the invalid config
Example fix
// before PasswordPolicyConfig custom = buildConfig(); // type not Jackson-serializable // after Use a config type with standard getters (POJO/record) compatible with JSON_OBJECT_MAPPER, or revert to Guardrails' default config
Defensive patterns
Strategy: try-catch
Validate before calling
// Before reading, verify the policy config was set from a known-good source
Object cfg = guardrails.getPasswordPolicyConfig();
if (cfg == null) logger.warn("No password policy config set; default will be serialized"); Try / catch
try {
String json = guardrails.getPasswordPolicyConfig();
} catch (RuntimeException e) {
if (e.getMessage().equals("Unable to serialize password_policy configuration")) {
logger.error("Password policy config not Jackson-serializable; resetting to default", e);
guardrails.setPasswordPolicy(defaultJson);
}
} Prevention
- Only set policy configs via supported setters with well-formed JSON
- Use standard POJO/record types with plain getters for custom config
- Keep Jackson dependency versions consistent with the Cassandra distribution
- Log the original cause server-side since this wrapper swallows it
When it happens
Trigger: Calling getPasswordPolicyConfig() when the stored password policy configuration object cannot be mapped to JSON by Jackson (e.g. an unmappable/irregular type or a getter throwing), typically after a custom or corrupt config was set via setPasswordPolicy.
Common situations: A configuration object type missing Jackson-accessible accessors; a classpath/Jackson version mismatch; setting a malformed policy programmatically before reading it back.
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
- It was not possible to generate a valid password in
- must be positive.
- The shortest password to pass the failing validator for any
- Unable to serialize minimum_client_driver_versions_warned…
- Unable to serialize…
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/b3c8588cdea578a7.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/db/guardrails/Guardrails.java:1587
return DEFAULT_CONFIG.getMaximumReplicationFactorFailThreshold();
}
@Override
public void setMaximumReplicationFactorThreshold (int warn, int fail)
{
DEFAULT_CONFIG.setMaximumReplicationFactorThreshold(warn, fail);
}
@Override
public String getPasswordPolicy()
{
try
{
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)View on GitHub (pinned to 88fd0f6a0e)