{"record":{"id":"4c9477cd7403c6aa","repo":"apache/cassandra","slug":"column-value-does-not-satisfy-value-constraint-for-4c9477","errorCode":null,"errorMessage":"Column value does not satisfy value constraint for column '<columnName>' as it is empty.","messagePattern":"Column value does not satisfy value constraint for column '<columnName>' as it is empty\\.","errorType":"validation","errorClass":"ConstraintViolationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/constraints/ConstraintFunction.java","lineNumber":74,"sourceCode":"        this.rawArgs = args;\n        this.args = unquote(args);\n    }\n\n    public List<String> arguments()\n    {\n        return args;\n    }\n\n    /**\n     * Method that performs the actual condition test, executed during the write path.\n     * It the test is not successful, it throws a {@link ConstraintViolationException}.\n     */\n    public void evaluate(AbstractType<?> valueType, Operator relationType, String term, ByteBuffer columnValue) throws ConstraintViolationException\n    {\n        if (columnValue == ByteBufferUtil.EMPTY_BYTE_BUFFER)\n            throw new ConstraintViolationException(\"Column value does not satisfy value constraint for column '\" + columnName + \"' as it is null.\");\n        else if (valueType.isEmptyValueMeaningless() && columnValue.capacity() == 0)\n            throw new ConstraintViolationException(\"Column value does not satisfy value constraint for column '\" + columnName + \"' as it is empty.\");\n\n        internalEvaluate(valueType, relationType, term, columnValue);\n    }\n\n    /**\n     * Internal evaluation method, by default called from {@link ConstraintFunction#evaluate(AbstractType, Operator, String, ByteBuffer)}.\n     * {@code columnValue} is by default guaranteed to not represent CQL value of 'null'.\n     */\n    protected abstract void internalEvaluate(AbstractType<?> valueType, Operator relationType, String term, ByteBuffer columnValue);\n\n    /**\n     * Used mostly for unary functions which do not expect any relation type nor term.\n     */\n    public void evaluate(AbstractType<?> valueType, ByteBuffer columnValue) throws ConstraintViolationException\n    {\n        evaluate(valueType, null, null, columnValue);\n    }\n","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/constraints/ConstraintFunction.java#L56-L92","documentation":"ConstraintFunction.evaluate rejects a column value that is an empty ByteBuffer when the value type declares isEmptyValueMeaningless() (e.g. int, uuid types whose zero-length encoding is meaningless). It throws ConstraintViolationException so constrained columns cannot hold such empty values. This runs on every write evaluated against the constraint.","triggerScenarios":"Writing a zero-capacity/empty byte buffer to a constrained column whose AbstractType reports isEmptyValueMeaningless() == true — e.g. binding an empty buffer for an int or timestamp column with a constraint, then evaluate() is invoked during the write path.","commonSituations":"Driver serialization bugs producing 0-length buffers for null-adjacent values; manually constructed ByteBuffers in tooling; migrating data where empty values were previously tolerated.","solutions":["Write a valid non-empty value (or a real default) instead of an empty buffer.","Remove the constraint if empty values must be allowed.","Ensure the client driver serializes null as null (not an empty buffer) for the column type."],"exampleFix":"// before\nboundValues[1] = ByteBuffer.allocate(0);\n// after\nboundValues[1] = value == null ? null : Int32Type.instance.decompose(value);","handlingStrategy":"try-catch","validationCode":"if (value != null && value.remaining() == 0 && valueType.isEmptyValueMeaningless())\n    throw new IllegalArgumentException(\"Empty buffer is invalid for constrained column \" + columnName);","typeGuard":"static boolean isValidBoundValue(ByteBuffer v) { return v == null || v.remaining() > 0; }","tryCatchPattern":"try {\n    session.execute(write);\n} catch (ConstraintViolationException e) {\n    if (e.getMessage().contains(\"as it is empty\")) {\n        // replace with a real value or null\n    } else throw e;\n}","preventionTips":["Use codec-aware binding (setInt/setString) instead of raw ByteBuffers","Check remaining() > 0 on manually built buffers before binding","Pin/verify driver versions that serialize null correctly for the type"],"tags":["cql","write-path","constraints","empty-value"],"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"}