{"record":{"id":"0d2bc0fae7043cde","repo":"apache/cassandra","slug":"non-finite-value-at-vector","errorCode":null,"errorMessage":"non-finite value at vector[","messagePattern":"non-finite value at vector\\[","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/index/sai/disk/v1/vector/OnHeapGraph.java","lineNumber":246,"sourceCode":"        // postings list already exists, just add the new key (if it's not already in the list)\n        if (postings.add(key))\n        {\n            bytesUsed += VectorPostings.bytesPerPosting();\n        }\n\n        return bytesUsed;\n    }\n\n    // copied out of a Lucene PR -- hopefully committed soon\n    public static final float MAX_FLOAT32_COMPONENT = 1E17f;\n\n    public static void checkInBounds(float[] v)\n    {\n        for (int i = 0; i < v.length; i++)\n        {\n            if (!Float.isFinite(v[i]))\n            {\n                throw new IllegalArgumentException(\"non-finite value at vector[\" + i + \"]=\" + v[i]);\n            }\n\n            if (Math.abs(v[i]) > MAX_FLOAT32_COMPONENT)\n            {\n                throw new IllegalArgumentException(\"Out-of-bounds value at vector[\" + i + \"]=\" + v[i]);\n            }\n        }\n    }\n\n    public static void validateIndexable(float[] vector, VectorSimilarityFunction similarityFunction)\n    {\n        try\n        {\n            checkInBounds(vector);\n        }\n        catch (IllegalArgumentException e)\n        {\n            throw new InvalidRequestException(e.getMessage());","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/index/sai/disk/v1/vector/OnHeapGraph.java#L228-L264","documentation":"IllegalArgumentException thrown by OnHeapGraph.checkInBounds when a float vector component is NaN or +/-Infinity. Vector similarity computations are undefined for non-finite components, so the graph index validates every vector before insertion. The message includes the component index and value.","triggerScenarios":"Inserting or indexing a vector produced from NaN/Infinity, e.g. dividing by zero while computing embeddings, decomposing malformed client-provided bytes into floats, or uninitialized float arrays.","commonSituations":"Client applications sending float2 vectors built from unvalidated model output, missing values encoded as NaN in embeddings, or float overflow (values beyond float32 range) during embedding computation.","solutions":["Validate/sanitize the embedding output before writing: replace or reject NaN/Infinity components","Check the embedding generation code for divide-by-zero, log(0), or overflow producing non-finite floats","Reject or fix the offending write at the application layer before sending to Cassandra","If reading existing data, identify and repair the rows containing non-finite vectors"],"exampleFix":"// before\nfloat[] v = computeEmbedding(input);\nsink.accept(v);\n// after\nfloat[] v = computeEmbedding(input);\nfor (float f : v)\n    if (!Float.isFinite(f)) throw new IllegalArgumentException(\"embedding contains non-finite value\");\nsink.accept(v);","handlingStrategy":"validation","validationCode":"for (float f : vector)\n    if (!Float.isFinite(f)) throw new IllegalArgumentException(\"vector contains non-finite component: \" + f);","typeGuard":"boolean isFiniteVector(float[] v) {\n    for (float f : v) if (!Float.isFinite(f)) return false;\n    return true;\n}","tryCatchPattern":"try {\n    vectorIndex.upsert(id, vector);\n} catch (IllegalArgumentException e) {\n    logger.warn(\"Rejected non-finite vector for id {}: {}\", id, e.getMessage());\n    sanitizeOrReject(vector);\n}","preventionTips":["Sanitize embedding model output before writing (replace NaN/Inf)","Check embedding math for divide-by-zero and log-of-zero","Add client-side vector validation in the write path"],"tags":["cassandra","sai","vector-search","validation"],"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-14T16:17:12.679Z"}