{"record":{"id":"19c7155e2f14ad74","repo":"apache/cassandra","slug":"invalid-empty-or-null-value-for-column-s","errorCode":null,"errorMessage":"Invalid empty or null value for column %s","messagePattern":"Invalid empty or null value for column (.+?)","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/RowUpdateBuilder.java","lineNumber":129,"sourceCode":"\n    @Override\n    public QueryOptions options()\n    {\n        return options;\n    }\n\n    public <V> void newRow(Clustering<V> clustering) throws InvalidRequestException\n    {\n        if (metadata.isCompactTable())\n        {\n            if (TableMetadata.Flag.isDense(metadata.flags) && !TableMetadata.Flag.isCompound(metadata.flags))\n            {\n                // If it's a COMPACT STORAGE table with a single clustering column and for backward compatibility we\n                // don't want to allow that to be empty (even though this would be fine for the storage engine).\n                assert clustering.size() == 1 : clustering.toString(metadata);\n                V value = clustering.get(0);\n                if (value == null || clustering.accessor().isEmpty(value))\n                    throw new InvalidRequestException(\"Invalid empty or null value for column \" + metadata.clusteringColumns().get(0).name);\n            }\n        }\n        assert builder == null : \"newRow called without building the previous row\";\n        builder = BTreeRow.pooledUnsortedBuilder();\n        builder.newRow(clustering);\n    }\n\n    public Clustering<?> currentClustering()\n    {\n        return builder.clustering();\n    }\n\n    public void addPrimaryKeyLivenessInfo()\n    {\n        addPrimaryKeyLivenessInfo(LivenessInfo.create(timestamp, ttl, nowInSec));\n    }\n\n    private void addPrimaryKeyLivenessInfo(LivenessInfo info)","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/RowUpdateBuilder.java#L111-L147","documentation":"In RowUpdateBuilder.newRow, for COMPACT STORAGE tables with a single clustering column, an empty or null clustering value is rejected even though the storage engine could technically represent it, for backward compatibility with the thrift-era behavior where the compact value could not be empty.","triggerScenarios":"Calling newRow() (directly or via addRow/applyUpdates) on a COMPACT STORAGE table whose single clustering column receives null or a zero-length value.","commonSituations":"Writing rows to legacy thrift-created COMPACT STORAGE tables from CQL/internal APIs with missing clustering values; deserializing records where the clustering component is absent; tests building updates with placeholder empty keys.","solutions":["Supply a non-empty value for the single clustering column","Skip rows whose clustering value is null/empty instead of building an update","Migrate the table off COMPACT STORAGE (ALTER ... WITH COMPACT STORAGE removal / re-create as regular table) where empty clustering is valid","Validate clustering values before calling newRow"],"exampleFix":"// before\nbuilder.newRow(clustering); // clustering.get(0) is empty byte buffer\n// after\nif (value == null || accessor.isEmpty(value)) return; // skip or fix value\nbuilder.newRow(clustering);","handlingStrategy":"validation","validationCode":"if (clusteringValue == null || clusteringValue.remaining() == 0)\n    throw new IllegalArgumentException(\"clustering value required for COMPACT STORAGE table\");","typeGuard":null,"tryCatchPattern":"try { builder.newRow(key).add(...); } catch (InvalidRequestException e) { if (e.getMessage().startsWith(\"Invalid empty or null value for column\")) skipOrFixRow(); else throw e; }","preventionTips":["Validate clustering components before building updates","Skip or repair source records with empty keys during migrations","Prefer regular (non-COMPACT STORAGE) tables for new schemas"],"tags":["compact-storage","clustering-key","write-path"],"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-17T15:17:12.973Z"}