{"record":{"id":"e4bd32202e7158d6","repo":"apache/cassandra","slug":"out-of-bound-timestamp-must-be-in-d-d-got","errorCode":null,"errorMessage":"Out of bound timestamp, must be in [%d, %d] (got %d)","messagePattern":"Out of bound timestamp, must be in \\[(.+?), (.+?)\\] \\(got (.+?)\\)","errorType":"validation","errorClass":"ProtocolException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/QueryOptions.java","lineNumber":769,"sourceCode":"                }\n            }\n\n            boolean skipMetadata = Flag.contains(flags, Flag.SKIP_METADATA);\n            flags = Flag.remove(flags, Flag.VALUES);\n            flags = Flag.remove(flags, Flag.SKIP_METADATA);\n\n            SpecificOptions options = SpecificOptions.DEFAULT;\n            if (!Flag.isEmpty(flags))\n            {\n                int pageSize = Flag.contains(flags, Flag.PAGE_SIZE) ? body.readInt() : -1;\n                PagingState pagingState = Flag.contains(flags, Flag.PAGING_STATE) ? PagingState.deserialize(CBUtil.readValueNoCopy(body), version) : null;\n                ConsistencyLevel serialConsistency = Flag.contains(flags, Flag.SERIAL_CONSISTENCY) ? CBUtil.readConsistencyLevel(body) : ConsistencyLevel.SERIAL;\n                long timestamp = Long.MIN_VALUE;\n                if (Flag.contains(flags, Flag.TIMESTAMP))\n                {\n                    long ts = body.readLong();\n                    if (ts == Long.MIN_VALUE)\n                        throw new ProtocolException(String.format(\"Out of bound timestamp, must be in [%d, %d] (got %d)\", Long.MIN_VALUE + 1, Long.MAX_VALUE, ts));\n                    timestamp = ts;\n                }\n                String keyspace = Flag.contains(flags, Flag.KEYSPACE) ? CBUtil.readString(body) : null;\n                long nowInSeconds = Flag.contains(flags, Flag.NOW_IN_SECONDS) ? CassandraUInt.toLong(body.readInt())\n                                                                              : UNSET_NOWINSEC;\n                boolean eligibleForArtificialLatency = Flag.contains(flags, Flag.ELIGIBLE_FOR_ARTIFICIAL_LATENCY);\n                options = new SpecificOptions(pageSize, pagingState, serialConsistency, timestamp, keyspace, nowInSeconds, eligibleForArtificialLatency);\n            }\n\n            DefaultQueryOptions opts = new DefaultQueryOptions(consistency, null, values, skipMetadata, options, version);\n            return names == null ? opts : new OptionsWithNames(opts, names);\n        }\n\n        public void encode(QueryOptions options, ByteBuf dest, ProtocolVersion version)\n        {\n            CBUtil.writeConsistencyLevel(options.getConsistency(), dest);\n\n            int flags = gatherFlags(options, version);","sourceCodeStart":751,"sourceCodeEnd":787,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/QueryOptions.java#L751-L787","documentation":"When a native-protocol v5+ client sends the TIMESTAMP flag in a QUERY/PREPARE message, the default write timestamp is read as a long. Long.MIN_VALUE is reserved internally as 'no timestamp', so a client sending exactly Long.MIN_VALUE is rejected with a ProtocolException during message decoding.","triggerScenarios":"A client explicitly sets the default timestamp to Long.MIN_VALUE (e.g. Session#setDeveloperDefaultTimestamp or driver config passing Long.MIN_VALUE) and issues a request over protocol v5+.","commonSituations":"Application code using Long.MIN_VALUE as a sentinel 'unset' timestamp; misconfigured driver default-timestamp option; handcrafted protocol clients.","solutions":["Change the client-provided timestamp to any value in [Long.MIN_VALUE+1, Long.MAX_VALUE].","If 'no timestamp' is desired, omit the TIMESTAMP flag instead of sending Long.MIN_VALUE.","Adjust driver configuration (e.g. default timestamp provider) to stop generating Long.MIN_VALUE."],"exampleFix":"// before\nlong ts = Long.MIN_VALUE; // rejected\n// after\nlong ts = System.currentTimeMillis() * 1000L; // microseconds","handlingStrategy":"validation","validationCode":"if (ts == Long.MIN_VALUE) throw new IllegalArgumentException(\"timestamp must be > Long.MIN_VALUE\");","typeGuard":null,"tryCatchPattern":"try { session.execute(stmt); } catch (ProtocolException e) { if (e.getMessage().startsWith(\"Out of bound timestamp\")) { /* fix timestamp source */ } }","preventionTips":["Never use Long.MIN_VALUE as a timestamp sentinel","Generate timestamps via currentTimeMillis()*1000 or driver defaults","Omit the TIMESTAMP flag instead of sending a reserved value"],"tags":["protocol","timestamp","native-protocol"],"backgroundTag":"value-out-of-range","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"}