{"record":{"id":"2f2032f476c39b37","repo":"apache/cassandra","slug":"is-not-empty","errorCode":null,"errorMessage":"' is not empty","messagePattern":"' is not empty","errorType":"validation","errorClass":"MarshalException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/marshal/EmptyType.java","lineNumber":101,"sourceCode":"    public <V> V fromComparableBytes(ValueAccessor<V> accessor, ByteSource.Peekable comparableBytes, ByteComparable.Version version)\n    {\n        return accessor.empty();\n    }\n\n    public <VL, VR> int compareCustom(VL left, ValueAccessor<VL> accessorL, VR right, ValueAccessor<VR> accessorR)\n    {\n        return 0;\n    }\n\n    public <V> String getString(V value, ValueAccessor<V> accessor)\n    {\n        return \"\";\n    }\n\n    public ByteBuffer fromString(String source) throws MarshalException\n    {\n        if (!source.isEmpty())\n            throw new MarshalException(String.format(\"'%s' is not empty\", source));\n\n        return ByteBufferUtil.EMPTY_BYTE_BUFFER;\n    }\n\n    @Override\n    public Term fromJSONObject(Object parsed) throws MarshalException\n    {\n        if (!(parsed instanceof String))\n            throw new MarshalException(String.format(\"Expected an empty string, but got: %s\", parsed));\n        if (!((String) parsed).isEmpty())\n            throw new MarshalException(String.format(\"'%s' is not empty\", parsed));\n\n        return new Constants.Value(ByteBufferUtil.EMPTY_BYTE_BUFFER);\n    }\n\n    @Override\n    public CQL3Type asCQL3Type()\n    {","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/marshal/EmptyType.java#L83-L119","documentation":"EmptyType is a type whose only valid value is the empty byte buffer. fromString() therefore rejects any non-empty string, throwing MarshalException quoting the offending string. It exists for columns/keys that must always be empty; anything else is invalid input.","triggerScenarios":"Calling EmptyType.instance.fromString(\"anything\") with a non-empty string, e.g. when CQL literal parsing or JSON-to-string conversion routes a real value into an empty-typed column.","commonSituations":"Column declared 'empty' type but application still sends values; tooling that generically calls fromString on all columns regardless of type.","solutions":["Pass an empty string \"\" if the column truly is of type empty","Remove or change the column type if real values need to be stored (use an appropriate type like text/int)","Ensure generic serializers special-case EmptyType and write empty values"],"exampleFix":"// before\nEmptyType.instance.fromString(\"hello\"); // MarshalException\n// after\nEmptyType.instance.fromString(\"\");","handlingStrategy":"type-guard","validationCode":"if (source != null && !source.isEmpty()) throw new IllegalArgumentException(\"EmptyType columns must be empty\");","typeGuard":null,"tryCatchPattern":"try { EmptyType.instance.fromString(source); } catch (MarshalException e) { /* treat as schema/payload mismatch */ }","preventionTips":["Special-case EmptyType columns in generic serializers so they always write empty values","Only use type 'empty' for placeholder columns that never store data","Audit queries writing into 'empty'-typed columns"],"tags":["cassandra","marshalling","empty-type"],"backgroundTag":"empty-required-field","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"}