{"record":{"id":"b3c8588cdea578a7","repo":"apache/cassandra","slug":"unable-to-serialize-password-policy-configuration","errorCode":null,"errorMessage":"Unable to serialize password_policy configuration","messagePattern":"Unable to serialize password_policy configuration","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/guardrails/Guardrails.java","lineNumber":1587,"sourceCode":"        return DEFAULT_CONFIG.getMaximumReplicationFactorFailThreshold();\n    }\n\n    @Override\n    public void setMaximumReplicationFactorThreshold (int warn, int fail)\n    {\n        DEFAULT_CONFIG.setMaximumReplicationFactorThreshold(warn, fail);\n    }\n\n    @Override\n    public String getPasswordPolicy()\n    {\n        try\n        {\n            return JsonUtils.JSON_OBJECT_MAPPER.writeValueAsString(passwordPolicy.getConfig());\n        }\n        catch (Throwable t)\n        {\n            throw new RuntimeException(\"Unable to serialize password_policy configuration\");\n        }\n    }\n\n    @Override\n    public String getRoleNamePolicy()\n    {\n        try\n        {\n            return JsonUtils.JSON_OBJECT_MAPPER.writeValueAsString(roleNamePolicy.getConfig());\n        }\n        catch (Throwable t)\n        {\n            throw new RuntimeException(\"Unable to serialize role_name_policy configuration\");\n        }\n    }\n\n    @Override\n    public void setPasswordPolicy(String value)","sourceCodeStart":1569,"sourceCodeEnd":1605,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/guardrails/Guardrails.java#L1569-L1605","documentation":"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.","triggerScenarios":"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.","commonSituations":"A configuration object type missing Jackson-accessible accessors; a classpath/Jackson version mismatch; setting a malformed policy programmatically before reading it back.","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"],"exampleFix":"// before\nPasswordPolicyConfig custom = buildConfig(); // type not Jackson-serializable\n// after\nUse a config type with standard getters (POJO/record) compatible with JSON_OBJECT_MAPPER, or revert to Guardrails' default config","handlingStrategy":"try-catch","validationCode":"// Before reading, verify the policy config was set from a known-good source\nObject cfg = guardrails.getPasswordPolicyConfig();\nif (cfg == null) logger.warn(\"No password policy config set; default will be serialized\");","typeGuard":null,"tryCatchPattern":"try {\n    String json = guardrails.getPasswordPolicyConfig();\n} catch (RuntimeException e) {\n    if (e.getMessage().equals(\"Unable to serialize password_policy configuration\")) {\n        logger.error(\"Password policy config not Jackson-serializable; resetting to default\", e);\n        guardrails.setPasswordPolicy(defaultJson);\n    }\n}","preventionTips":["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"],"tags":["guardrails","json-serialization","password-policy"],"backgroundTag":"json-serialization-failed","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}