{"record":{"id":"a6463b05b7e76169","repo":"apache/cassandra","slug":"id-is-not-a-valid-transformation-kind-id","errorCode":null,"errorMessage":"<id> is not a valid Transformation.Kind id","messagePattern":"<id> is not a valid Transformation\\.Kind id","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/functions/ClusterMetadataFcts.java","lineNumber":50,"sourceCode":"    {\n        functions.add(transformationKind);\n    }\n\n    public static final NativeScalarFunction transformationKind = new TransformationKind();\n    private static final class TransformationKind extends NativeScalarFunction\n    {\n\n        private TransformationKind()\n        {\n            super(\"transformation_kind\", UTF8Type.instance, Int32Type.instance);\n        }\n\n        @Override\n        public ByteBuffer execute(Arguments arguments) throws InvalidRequestException\n        {\n            Number id = arguments.get(0);\n            if (id.intValue() < 0 || id.intValue() > Transformation.Kind.values().length -1)\n                throw new InvalidRequestException(id + \" is not a valid Transformation.Kind id\");\n\n            Transformation.Kind kind = Transformation.Kind.fromId(id.intValue());\n            return ByteBufferUtil.bytes(kind.name());\n\n        }\n    }\n}\n","sourceCodeStart":32,"sourceCodeEnd":58,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/functions/ClusterMetadataFcts.java#L32-L58","documentation":"Thrown by the ClusterMetadataFcts Transformation.Kind function when the supplied integer id is outside the valid range [0, Transformation.Kind.values().length - 1]. The function maps a kind id to its name, and out-of-range ids are rejected with InvalidRequestException.","triggerScenarios":"Calling the Transformation.Kind id-to-name function with n < 0 or n >= number of Transformation.Kind enum constants; typically hard-coded ids copied from a different Cassandra version.","commonSituations":"Scripts written against an older/newer Cassandra where the Transformation.Kind enum had different members; negative values from failed computations; iterating with an off-by-one bound.","solutions":["Pass an id in the valid range 0..(number of Transformation.Kind values - 1) for the running Cassandra version.","Derive valid ids from the enum in the running version instead of hard-coding them.","Filter out-of-range ids in the query layer before calling the function."],"exampleFix":"// before: SELECT kindName(-1) ...; -- rejected\n// after\nSELECT kindName(0) ...;","handlingStrategy":"validation","validationCode":"// Java: bound-check the id against the enum of the running version\nboolean valid = id >= 0 && id <= Transformation.Kind.values().length - 1;","typeGuard":null,"tryCatchPattern":"catch (InvalidRequestException e) { if (e.getMessage().endsWith(\"is not a valid Transformation.Kind id\")) { log.warn(\"kind id out of range\"); } }","preventionTips":["Never hard-code enum ids; derive them at runtime.","Re-verify ids after Cassandra upgrades (enum may change).","Loop with i < Kind.values().length, not <=."],"tags":["cassandra","cql","function","enum"],"backgroundTag":"value-out-of-range","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"}