{"record":{"id":"7f8795e6ed8c6640","repo":"apache/cassandra","slug":"unable-to-parse-value-s","errorCode":null,"errorMessage":"Unable to parse value %s","messagePattern":"Unable to parse value (.+?)","errorType":"console","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tools/nodetool/GuardrailsConfigCommand.java","lineNumber":349,"sourceCode":"            }\n            else\n            {\n                throw new IllegalArgumentException(format(\"unsupported type: %s\", targetType));\n            }\n        }\n\n        private <T> T getNumber(String value, Function<String, T> transformer, T defaultValue)\n        {\n            if (value == null || value.equals(\"null\"))\n                return defaultValue;\n\n            try\n            {\n                return transformer.apply(value);\n            }\n            catch (NumberFormatException ex)\n            {\n                throw new IllegalStateException(format(\"Unable to parse value %s\", value), ex);\n            }\n        }\n    }\n\n    private static final Pattern CAMEL_PATTERN = Pattern.compile(\"([a-z])([A-Z])\");\n\n    /**\n     * Special map for methods which do not adhere to camel-case convention precisely.\n     * These will be translated manually.\n     */\n    private static final Map<String, String> toSnakeCaseTranslationMap = Map.of(\"ZeroTTLOnTWCSEnabled\", \"zero_ttl_on_twcs_enabled\",\n                                                                                \"ZeroTTLOnTWCSWarned\", \"zero_ttl_on_twcs_warned\",\n                                                                                \"FieldsPerUDTFailThreshold\", \"fields_per_udt_fail_threshold\",\n                                                                                \"FieldsPerUDTWarnThreshold\", \"fields_per_udt_warn_threshold\",\n                                                                                \"FieldsPerUDTThreshold\", \"fields_per_udt_threshold\",\n                                                                                \"SimpleStrategyEnabled\", \"simplestrategy_enabled\",\n                                                                                \"NonPartitionRestrictedQueryEnabled\", \"non_partition_restricted_index_query_enabled\");\n","sourceCodeStart":331,"sourceCodeEnd":367,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tools/nodetool/GuardrailsConfigCommand.java#L331-L367","documentation":"GuardrailsConfigCommand.getNumber applies a numeric transformer (e.g. Integer.parseInt) to the user-supplied option value. If the value is not a valid number, NumberFormatException is caught and rethrown as IllegalStateException with 'Unable to parse value <value>'. This means the CLI argument passed for a numeric guardrail property is not parseable as the expected number type.","triggerScenarios":"`nodetool guardrails-config` set with a numeric property given a non-numeric value, e.g. `--warning-threshold=ten` or `5,000` with a thousands separator; an empty string; negative sign mistakes or locale-specific formatting.","commonSituations":"Typing a percentage with a % sign, using comma thousands separators, pasting values with trailing whitespace, or setting a value to text by accident in shell scripts.","solutions":["Pass a plain unformatted number, e.g. `--warning-threshold=5000`","Strip units/separators/whitespace before passing the value in scripts","Verify the property actually expects a number and not a set/string value","Check the exception's cause (NumberFormatException) for the exact offending string"],"exampleFix":"// before\nnodetool guardrails-config set read-risk --warning-threshold=\"5,000\"\n// after\nnodetool guardrails-config set read-risk --warning-threshold=5000","handlingStrategy":"validation","validationCode":"// validate numeric shell variable before passing to nodetool\n[[ \"$VAL\" =~ ^-?[0-9]+$ ]] || { echo \"VAL must be an integer\"; exit 1; }","typeGuard":null,"tryCatchPattern":"try { runNodetool(\"guardrails-config\",\"set\",prop,\"--warning-threshold=\"+val); } catch (IllegalStateException e) { log(\"Bad numeric value: \" + val, e); }","preventionTips":["Never pass formatted numbers (commas, %, units) to numeric nodetool options","Trim whitespace in scripts before interpolating values","Check the NumberFormatException cause to confirm the offending string"],"tags":["nodetool","cli","number-format","validation"],"backgroundTag":"invalid-argument-format","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"}