{"record":{"id":"a924930ed83e0541","repo":"apache/cassandra","slug":"invalid-value-d-for-s-maximum-allowed-value-is","errorCode":null,"errorMessage":"Invalid value %d for %s: maximum allowed value is %d","messagePattern":"Invalid value (.+?) for (.+?): maximum allowed value is (.+?)","errorType":"validation","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/config/GuardrailsOptions.java","lineNumber":1494,"sourceCode":"    }\n\n    private static <T> void updatePropertyWithLogging(String propertyName, T newValue, Supplier<T> getter, Consumer<T> setter)\n    {\n        T oldValue = getter.get();\n        if (newValue == null || !newValue.equals(oldValue))\n        {\n            setter.accept(newValue);\n            logger.info(\"Updated {} from {} to {}\", propertyName, oldValue, newValue);\n        }\n    }\n\n    private static void validatePositiveNumeric(long value, long maxValue, String name)\n    {\n        if (value == -1)\n            return;\n\n        if (value > maxValue)\n            throw new IllegalArgumentException(format(\"Invalid value %d for %s: maximum allowed value is %d\",\n                                                      value, name, maxValue));\n\n        // Zero is a valid threshold, meaning \"any value above zero triggers the guardrail\". \n        // We allow -1 as a general \"disabling\" flag, but reject anything lower to avoid mistakes.\n        if (value < 0)\n            throw new IllegalArgumentException(format(\"Invalid value %d for %s: negative values are not allowed, \" +\n                                                      \"outside of -1 which disables the guardrail\", value, name));\n    }\n\n    private static void validatePercentage(long value, String name)\n    {\n        validatePositiveNumeric(value, 100, name);\n    }\n\n    private static void validatePercentageThreshold(int warn, int fail, String name)\n    {\n        validatePercentage(warn, name + \"_warn_threshold\");\n        validatePercentage(fail, name + \"_fail_threshold\");","sourceCodeStart":1476,"sourceCodeEnd":1512,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/config/GuardrailsOptions.java#L1476-L1512","documentation":"GuardrailsOptions.validatePositiveNumeric validates numeric guardrail thresholds: -1 means disabled, 0 is a valid trigger-above-zero threshold, and any value above the guardrail's maximum (or negative) is rejected with IllegalArgumentException. This enforces per-guardrail upper limits in cassandra.yaml / guardrails config.","triggerScenarios":"Setting a numeric guardrail (e.g. partition_size_in_mb style thresholds, fields_per_table, collections_per_inner_table limits) to a value larger than that guardrail's defined maximum, via YAML or a guardrails setter.","commonSituations":"Typo adding an extra digit; copying a limit from another cluster with different caps; setting -2/-5 intending 'disabled' instead of the documented -1.","solutions":["Set the value to at most the printed maximum for that guardrail","Use -1 to disable the guardrail (not other negatives)","Use 0 if the intent is 'any value above zero triggers'","Check the guardrail's definition for its max constant"],"exampleFix":"// before (max 256)\nfields_per_table:\n  warn_threshold: 1000\n// after\nfields_per_table:\n  warn_threshold: 200","handlingStrategy":"validation","validationCode":"static void checkGuardrailValue(long v, long max, String name) {\n    if (v == -1 || v == 0) return;\n    if (v > max) throw new IllegalArgumentException(name + \" max is \" + max);\n    if (v < 0) throw new IllegalArgumentException(name + \" negative not allowed; use -1 to disable\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    guardrails.setFieldsPerTableWarn(1000);\n} catch (IllegalArgumentException e) {\n    logger.error(\"Guardrail value rejected: {}\", e.getMessage());\n}","preventionTips":["Use -1 only for disable; never other negatives","Treat 0 as a valid threshold meaning 'above zero triggers'","Keep guardrail values within documented maxima per Cassandra version"],"tags":["guardrails","configuration","bounds"],"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-14T16:17:12.679Z"}