{"record":{"id":"ab6e1847bb78c790","repo":"apache/cassandra","slug":"write-operation-require-a-read-but-consistency-s","errorCode":null,"errorMessage":"Write operation require a read but consistency %s is not supported on reads","messagePattern":"Write operation require a read but consistency (.+?) is not supported on reads","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java","lineNumber":652,"sourceCode":"    private <F> Map<DecoratedKey, Partition> readRequiredLists(Collection<ByteBuffer> partitionKeys,\n                                                           java.util.function.Function<F, ClusteringIndexFilter> filterBuilder,\n                                                           F filterArg,\n                                                           DataLimits limits,\n                                                           boolean local,\n                                                           ConsistencyLevel cl,\n                                                           long nowInSeconds,\n                                                           Dispatcher.RequestTime requestTime)\n    {\n        if (!requiresRead())\n            return null;\n\n        try\n        {\n            cl.validateForRead();\n        }\n        catch (InvalidRequestException e)\n        {\n            throw new InvalidRequestException(String.format(\"Write operation require a read but consistency %s is not supported on reads\", cl));\n        }\n\n        List<SinglePartitionReadCommand> commands = new ArrayList<>(partitionKeys.size());\n        for (ByteBuffer key : partitionKeys)\n            commands.add(SinglePartitionReadCommand.create(metadata(),\n                                                           nowInSeconds,\n                                                           ColumnFilter.selection(this.requiresRead),\n                                                           RowFilter.none(),\n                                                           limits,\n                                                           metadata().partitioner.decorateKey(key),\n                                                           filterBuilder.apply(filterArg)));\n\n        SinglePartitionReadCommand.Group group = SinglePartitionReadCommand.Group.create(commands, DataLimits.NONE);\n\n        if (local)\n        {\n            try (ReadExecutionController executionController = group.executionController();\n                 PartitionIterator iter = group.executeInternal(executionController))","sourceCodeStart":634,"sourceCodeEnd":670,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java#L634-L670","documentation":"ModificationStatement.readRequiredLists() is used when a write (e.g. UPDATE with a list add/remove) must first read existing data. Before issuing those reads it validates the statement's consistency level via cl.validateForRead(); if the level is invalid for reads (e.g. SOME variants of serial write levels), this InvalidRequestException is thrown naming the offending level.","triggerScenarios":"Executing an UPDATE or DELETE that touches list columns (read-before-write) with a consistency level that fails validateForRead(), e.g. passing an inappropriate CL to the driver for such a statement.","commonSituations":"Application configures a custom consistency level globally, then runs list mutations; scripts generated for normal writes reused for list writes.","solutions":["Check the consistency level being sent with the list-modifying statement and switch to a level valid for reads (e.g. ONE/QUORUM).","Verify client-side CL configuration; set per-statement CL instead of a global invalid one.","Ensure the driver/tool is not sending serial-only levels as regular consistency."],"exampleFix":"// before\nstmt.setConsistencyLevel(ConsistencyLevel.LOCAL_SERIAL); // invalid for the read phase\n// after\nstmt.setConsistencyLevel(ConsistencyLevel.QUORUM);","handlingStrategy":"validation","validationCode":"if (stmtTouchingLists && !isReadValidConsistency(cl)) { cl = ConsistencyLevel.QUORUM; }","typeGuard":null,"tryCatchPattern":"try { session.execute(stmt); } catch (InvalidRequestException e) { if (e.getMessage().contains(\"not supported on reads\")) { /* fix CL and retry */ } else throw e; }","preventionTips":["Use standard consistency levels (ONE..QUORUM) for list mutations","Avoid serial consistency levels as regular CL","Pin per-statement CL in the driver rather than globally"],"tags":["cql","consistency-level","invalid-request"],"backgroundTag":"invalid-enum-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"}