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

  1. Reproduce to expose the hidden Jackson cause (the message omits it); check server logs
  2. Reset role_name_policy to the default via the corresponding setter and retry
  3. Align Jackson versions / remove conflicting jackson-databind jars from the classpath
  4. 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

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


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)