{"record":{"id":"640eefb34ac26466","repo":"apache/cassandra","slug":"out-of-bound-timestamp-must-be-in-d-d","errorCode":null,"errorMessage":"Out of bound timestamp, must be in [%d, %d]","messagePattern":"Out of bound timestamp, must be in \\[(.+?), (.+?)\\]","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/RowUpdateBuilder.java","lineNumber":104,"sourceCode":"                            QueryOptions options,\n                            long timestamp,\n                            long nowInSec,\n                            int ttl,\n                            Map<DecoratedKey, Partition> prefetchedRows) throws InvalidRequestException\n    {\n        this.metadata = metadata;\n        this.options = options;\n        this.clientState = clientState;\n        this.nowInSec = nowInSec;\n        this.timestamp = timestamp;\n        this.ttl = ttl;\n\n        this.deletionTime = DeletionTime.build(timestamp, nowInSec);\n        this.prefetchedRows = prefetchedRows;\n        // We use MIN_VALUE internally to mean the absence of of timestamp (in Selection, in sstable stats, ...), so exclude\n        // it to avoid potential confusion.\n        if (timestamp == Long.MIN_VALUE)\n            throw new InvalidRequestException(String.format(\"Out of bound timestamp, must be in [%d, %d]\", Long.MIN_VALUE + 1, Long.MAX_VALUE));\n\n        areValueSizeGuardrailsEnabled = Guardrails.columnValueSize.enabled(clientState)\n                                        || Guardrails.columnBlobValueSize.enabled(clientState)\n                                        || Guardrails.columnAsciiValueSize.enabled(clientState)\n                                        || Guardrails.columnTextAndVarcharValueSize.enabled(clientState);\n    }\n\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))","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/RowUpdateBuilder.java#L86-L122","documentation":"RowUpdateBuilder stores the write timestamp in the DeletionTime; Long.MIN_VALUE is reserved internally to mean 'no timestamp' (in Selection, sstable stats, etc.), so a caller passing exactly Long.MIN_VALUE as the timestamp is rejected with InvalidRequestException to avoid that sentinel colliding with a real timestamp.","triggerScenarios":"Calling new RowUpdateBuilder(...) (or mutations built from it, e.g. in internal code/tests) with timestamp == Long.MIN_VALUE, typically from uninitialized `long timestamp = Long.MIN_VALUE` defaults or clients using Long.MIN_VALUE as 'unset'.","commonSituations":"Internal tooling/tests that default a timestamp field to Long.MIN_VALUE; deserializing client timestamps where an 'unset' marker was mapped to Long.MIN_VALUE; arithmetic underflow when computing timestamps (e.g. base - offset).","solutions":["Use a valid timestamp in [Long.MIN_VALUE+1, Long.MAX_VALUE]; pick micros-since-epoch values","Replace Long.MIN_VALUE 'unset' sentinels with a separate boolean/Optional before building the update","Guard timestamp computation against underflow","If you truly don't care, let the builder use the default now-based timestamp instead of passing one"],"exampleFix":"// before\nlong ts = Long.MIN_VALUE; // 'unset'\nnew RowUpdateBuilder(cfm, now, ts).newRow(key).add(...);\n// after\nlong ts = unset ? FBUtilities.timestampMicros() : providedTs; // never MIN_VALUE\nnew RowUpdateBuilder(cfm, now, ts).newRow(key).add(...);","handlingStrategy":"validation","validationCode":"if (timestamp == Long.MIN_VALUE) timestamp = System.currentTimeMillis() * 1000; // or reject","typeGuard":null,"tryCatchPattern":"try { new RowUpdateBuilder(cfm, now, ts)...; } catch (InvalidRequestException e) { if (e.getMessage().startsWith(\"Out of bound timestamp\")) useDefaultTimestamp(); else throw e; }","preventionTips":["Never use Long.MIN_VALUE as an 'unset' timestamp sentinel","Use microsecond timestamps from clock APIs","Guard timestamp arithmetic against underflow"],"tags":["timestamp","write-path","validation"],"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"}