{"record":{"id":"a7a4eb475457ec77","repo":"apache/cassandra","slug":"vectors-may-only-have-positive-dimensions-given","errorCode":null,"errorMessage":"vectors may only have positive dimensions; given %d","messagePattern":"vectors may only have positive dimensions; given (.+?)","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/marshal/VectorType.java","lineNumber":91,"sourceCode":"        @Override\n        public int hashCode()\n        {\n            return Objects.hash(type, dimension);\n        }\n    }\n    @SuppressWarnings(\"rawtypes\")\n    private static final ConcurrentHashMap<Key, VectorType> instances = new ConcurrentHashMap<>();\n\n    public final AbstractType<T> elementType;\n    public final int dimension;\n    private final TypeSerializer<T> elementSerializer;\n    private final VectorSerializer serializer;\n\n    private VectorType(AbstractType<T> elementType, int dimension)\n    {\n        super(ComparisonType.CUSTOM, valueLengthIfFixed(elementType, dimension));\n        if (dimension <= 0)\n            throw new InvalidRequestException(String.format(\"vectors may only have positive dimensions; given %d\", dimension));\n        this.elementType = elementType;\n        this.dimension = dimension;\n        this.elementSerializer = elementType.getSerializer();\n        this.serializer = elementType.isValueLengthFixed() ?\n                          new FixedLengthSerializer() :\n                          new VariableLengthSerializer();\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public static <T> VectorType<T> getInstance(AbstractType<T> elements, int dimension)\n    {\n        Key key = new Key(elements, dimension);\n        return instances.computeIfAbsent(key, Key::create);\n    }\n\n    public static VectorType<?> getInstance(TypeParser parser)\n    {\n        TypeParser.Vector v = parser.getVectorParameters();","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/marshal/VectorType.java#L73-L109","documentation":"VectorType requires a strictly positive dimension when a vector type is constructed. The constructor validates the dimension parameter and throws InvalidRequestException if it is <= 0, because a vector with zero or negative elements is meaningless in CQL.","triggerScenarios":"Calling VectorType.getInstance(elementType, dimension) with dimension = 0 or a negative number, or declaring a CQL type like vector<int, 0> which resolves to a VectorType construction with an invalid dimension.","commonSituations":"Typo or computed dimension passed as 0 (e.g. a config value or variable that defaulted to 0), schema generation code building vector types programmatically, or user-supplied DDL with vector<..., 0>.","solutions":["Pass a positive dimension (>= 1) when constructing the vector type","Fix the CQL schema to declare vector<elementType, N> with N > 0","If dimension comes from a variable/config, validate it is > 0 before calling VectorType.getInstance"],"exampleFix":"// before\nAbstractType<?> t = VectorType.getInstance(Int32Type.instance, 0);\n// after\nAbstractType<?> t = VectorType.getInstance(Int32Type.instance, 3);","handlingStrategy":"validation","validationCode":"if (dimension <= 0) throw new IllegalArgumentException(\"dimension must be > 0, got \" + dimension);\nAbstractType<?> t = VectorType.getInstance(elementType, dimension);","typeGuard":null,"tryCatchPattern":"try { VectorType.getInstance(et, dim); } catch (InvalidRequestException e) { /* log and fail schema setup */ }","preventionTips":["Validate dimension > 0 before constructing vector types","Never hardcode dimensions from unchecked config values"],"tags":["cassandra","vector-type","schema","invalid-dimension"],"backgroundTag":"invalid-argument-value","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"}