{"record":{"id":"17f34fe46ffbb797","repo":"apache/cassandra","slug":"value-of-s-is-not-a-string","errorCode":null,"errorMessage":"Value of %s is not a string.","messagePattern":"Value of (.+?) is not a string\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/guardrails/UUIDRoleNameGenerator.java","lineNumber":135,"sourceCode":"    {\n        if (minimumNameSize < DEFAULT_MINIMUM_NAME_SIZE || minimumNameSize > MAXIMUM_NAME_SIZE)\n            throw new ConfigurationException(MINIMUM_NAME_SIZE_CONFIG_OPTION + \" has to be at least \" + DEFAULT_MINIMUM_NAME_SIZE + \" and at most \" + MAXIMUM_NAME_SIZE);\n    }\n\n    private String enrich(String key, String generatedValue, Map<String, Object> options)\n    {\n        if (options == null || options.isEmpty())\n            return generatedValue;\n\n        if (options.containsKey(key))\n        {\n            Object value = options.get(key);\n\n            if (value == null)\n                throw new IllegalArgumentException(\"Value of \" + key + \" cannot be null.\");\n\n            if (!(value instanceof String))\n                throw new IllegalArgumentException(\"Value of \" + key + \" is not a string.\");\n\n            if (NAME_PREFIX_KEY.equals(key))\n                generatedValue = value + generatedValue;\n            else if (NAME_SUFFIX_KEY.equals(key))\n                generatedValue = generatedValue + value;\n        }\n\n        return generatedValue;\n    }\n\n    private int getSize(Map<String, Object> options)\n    {\n        Object sizeObject;\n        if (options == null)\n        {\n            sizeObject = MAXIMUM_NAME_SIZE;\n        }\n        else if (options.containsKey(NAME_SIZE))","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/guardrails/UUIDRoleNameGenerator.java#L117-L153","documentation":"Thrown by UUIDRoleNameGenerator.enrich() when a value in the options map for a known key (name_prefix, name_suffix, name_size) is present but is not a String. The generator only understands string-typed option values even for name_size.","triggerScenarios":"Calling generate(options) with e.g. options.put(\"name_size\", 8) (Integer) or a non-string prefix like options.put(\"name_prefix\", 123), or a config layer deserializing numbers as Integer/Long.","commonSituations":"Passing parsed YAML/JSON maps where scalars become Integer/Boolean automatically instead of strings; building options in code with native types.","solutions":["Convert all option values to String before calling generate, e.g. String.valueOf(value)","For name_size pass the number as a string: \"name_size\" -> \"8\"","Check the message for the key name and fix that entry's type"],"exampleFix":"// before\noptions.put(\"name_prefix\", 42);\n// after\noptions.put(\"name_prefix\", \"42\");","handlingStrategy":"type-guard","validationCode":"for (var e : options.entrySet())\n    if (e.getValue() != null && !(e.getValue() instanceof String))\n        throw new IllegalArgumentException(\"non-string value for option: \" + e.getKey());","typeGuard":"boolean allStringValues(Map<String,Object> options) {\n    return options.values().stream().allMatch(v -> v == null || v instanceof String);\n}","tryCatchPattern":"try {\n    generator.generate(options);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"is not a string\")) {\n        // coerce offending entry via String.valueOf and retry\n    } else throw e;\n}","preventionTips":["Convert every option value with String.valueOf before calling generate","Remember name_size must also be a string (or the map passed as raw objects must keep it string) when using enrich paths","Disable implicit YAML/JSON scalar typing when building the options map"],"tags":["guardrails","type-mismatch","options","arguments"],"backgroundTag":"type-mismatch","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}