{"record":{"id":"9ac6f6e74c62c73e","repo":"apache/cassandra","slug":"unable-to-parse-value-s-of-key-s-value-has-to-b","errorCode":null,"errorMessage":"Unable to parse value %s of key %s. Value has to be integer. The default of value %s will be used.","messagePattern":"Unable to parse value (.+?) of key (.+?)\\. Value has to be integer\\. The default of value (.+?) will be used\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/java/org/apache/cassandra/db/guardrails/CustomGuardrailConfig.java","lineNumber":84,"sourceCode":"    public int resolveInteger(@Nullable String key, Integer defaultValue)\n    {\n        if (key == null)\n            return defaultValue;\n\n        Object resolvedValue = getOrDefault(key, defaultValue.toString());\n\n        try\n        {\n            if (resolvedValue instanceof Integer)\n                return (Integer) resolvedValue;\n            if (resolvedValue instanceof String)\n                return Integer.parseInt((String) resolvedValue);\n\n            throw new IllegalStateException();\n        }\n        catch (IllegalStateException | NumberFormatException ex)\n        {\n            logger.warn(format(\"Unable to parse value %s of key %s. Value has to be integer. \" +\n                               \"The default of value %s will be used.\",\n                               resolvedValue, key, defaultValue));\n        }\n        return defaultValue;\n    }\n\n    public boolean resolveBoolean(@Nullable String key, boolean defaultValue)\n    {\n        Object value = get(key);\n\n        if (value == null)\n            return defaultValue;\n        if (value instanceof Boolean)\n            return (boolean) value;\n        if (value instanceof String)\n            return Boolean.parseBoolean((String) value);\n\n        return defaultValue;","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/guardrails/CustomGuardrailConfig.java#L66-L102","documentation":"CustomGuardrailConfig.resolveInteger parses a guardrail config value expected to be a String containing an integer. If the value cannot be parsed (NumberFormatException) or the value type is unsupported (IllegalStateException), the method logs this warning and falls back to the configured default value instead of failing startup.","triggerScenarios":"Setting a guardrail config key (e.g. via cassandra.yaml guardrails configuration or a custom guardrail's config map) to a non-integer string like \"abc\" or \"10.5\", or to a non-String object (e.g. Integer or Boolean), when resolveInteger is called by CassandraPasswordConfiguration or UUIDRoleNameGenerator during guardrail initialization.","commonSituations":"Typo or wrong unit in a YAML guardrail value (e.g. 'password length: ten'); YAML auto-typing turning a quoted number into a non-String type; copying config between versions where the value format changed.","solutions":["Fix the config value for the offending key to be a valid integer string (e.g. '12' not 'twelve' or '12.0').","Check the warn log line for the key and resolved value to identify which key is wrong.","If the value is intentionally a non-String type, quote it in YAML or adjust the custom guardrail's config parsing to accept that type.","Remove the key so the guardrail uses its default value."],"exampleFix":"// before (cassandra.yaml)\ncustom_guardrails:\n  - name: password_policy\n    password_min_length: ten\n// after\nliquid(custom_guardrails):\n  - name: password_policy\n    password_min_length: 10","handlingStrategy":"validation","validationCode":"Object v = config.get(key);\nif (!(v instanceof String) || !((String) v).matches(\"-?\\\\d+\")) {\n    throw new IllegalArgumentException(\"Key \" + key + \" must be an integer string, got: \" + v);\n}","typeGuard":"boolean isIntegerString(Object v) { return v instanceof String && ((String) v).matches(\"-?\\\\d+\"); }","tryCatchPattern":null,"preventionTips":["Quote integer values in YAML if the schema expects Strings.","Validate guardrail config maps at deploy time with a schema check.","Grep logs for this warning after every config change."],"tags":["config","guardrails","type-mismatch"],"backgroundTag":"invalid-config-value","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"}