{"record":{"id":"73e921e2dacb489e","repo":"apache/cassandra","slug":"unsupported-object-passed-to-resolve-name-size-s","errorCode":null,"errorMessage":"Unsupported object passed to resolve name_size: %s","messagePattern":"Unsupported object passed to resolve name_size: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/guardrails/UUIDRoleNameGenerator.java","lineNumber":182,"sourceCode":"        }\n\n        int size;\n\n        if (sizeObject instanceof String)\n        {\n            try\n            {\n                size = Integer.parseInt((String) sizeObject);\n            }\n            catch (Throwable t)\n            {\n                throw new IllegalArgumentException(\"Value '\" + sizeObject + \"' can't be converted to integer.\");\n            }\n        }\n        else if (sizeObject instanceof Number)\n            size = ((Number) sizeObject).intValue();\n        else\n            throw new IllegalArgumentException(\"Unsupported object passed to resolve \" + NAME_SIZE + \": \" + sizeObject.getClass().getName());\n\n        if (size < minimumNameSize)\n            throw new IllegalArgumentException(\"Value of \" + NAME_SIZE + \" parameter has to be at least \" + minimumNameSize + '.');\n\n        if (size > MAXIMUM_NAME_SIZE)\n            throw new IllegalArgumentException(\"Generator generates names of maximum length \" + MAXIMUM_NAME_SIZE + \". \" +\n                                               \"You want to generate with length \" + size + '.');\n\n        return size;\n    }\n}\n","sourceCodeStart":164,"sourceCodeEnd":194,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/guardrails/UUIDRoleNameGenerator.java#L164-L194","documentation":"Thrown by UUIDRoleNameGenerator.getSize() when the resolved name_size object is neither a String nor a Number — i.e. an unsupported type such as Boolean, Map, or List. The message includes the class name of the offending object.","triggerScenarios":"Calling generate(options) with options.get(\"name_size\") being any object that is not String or Number, e.g. a nested map from a misparsed config.","commonSituations":"Config layers deserializing 'name_size' into unexpected types (e.g. a YAML mapping instead of a scalar); programmatic misuse passing an enum or object wrapper.","solutions":["Ensure name_size is a String or Number before calling generate","Fix config so name_size is a scalar integer value, not a nested structure","Pre-validate with an instanceof (String || Number) check"],"exampleFix":"// before\noptions.put(\"name_size\", Map.of(\"min\", 8));\n// after\noptions.put(\"name_size\", \"8\");","handlingStrategy":"type-guard","validationCode":"Object v = options.get(\"name_size\");\nif (v != null && !(v instanceof String) && !(v instanceof Number))\n    throw new IllegalArgumentException(\"name_size must be String or Number\");","typeGuard":"boolean isStringOrNumber(Object v) { return v instanceof String || v instanceof Number; }","tryCatchPattern":"try {\n    generator.generate(options);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"Unsupported object passed to resolve name_size\")) {\n        // coerce the value to a String/Number and retry\n    } else throw e;\n}","preventionTips":["Ensure config deserialization yields scalar values for name_size","Pre-check instanceof String/Number before calling generate","Log the class name (per the message) to find the misconfigured source"],"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"}