{"record":{"id":"bf90c33ea2705ecb","repo":"VictoriaMetrics/VictoriaMetrics","slug":"cannot-read-mintimestamp-w","errorCode":null,"errorMessage":"cannot read minTimestamp: %w","messagePattern":"cannot read minTimestamp: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/vmselectapi/server.go","lineNumber":299,"sourceCode":"\tbc      *handshake.BufferedConn\n\tsizeBuf []byte\n\tdataBuf []byte\n\n\tqt *querytracer.Tracer\n\tsq storage.SearchQuery\n\n\t// timeout in seconds for the current request\n\ttimeout uint64\n\n\t// deadline in unix timestamp seconds for the current request.\n\tdeadline uint64\n}\n\nfunc (ctx *vmselectRequestCtx) readTimeRange() (storage.TimeRange, error) {\n\tvar tr storage.TimeRange\n\tminTimestamp, err := ctx.readUint64()\n\tif err != nil {\n\t\treturn tr, fmt.Errorf(\"cannot read minTimestamp: %w\", err)\n\t}\n\tmaxTimestamp, err := ctx.readUint64()\n\tif err != nil {\n\t\treturn tr, fmt.Errorf(\"cannot read maxTimestamp: %w\", err)\n\t}\n\ttr.MinTimestamp = int64(minTimestamp)\n\ttr.MaxTimestamp = int64(maxTimestamp)\n\treturn tr, nil\n}\n\nfunc (ctx *vmselectRequestCtx) readLimit() (int, error) {\n\tn, err := ctx.readUint32()\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"cannot read limit: %w\", err)\n\t}\n\tif n > 1<<31-1 {\n\t\tn = 1<<31 - 1\n\t}","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/VictoriaMetrics/VictoriaMetrics/blob/5079fb58f1e8e62113f90c945ad71586c797d770/lib/vmselectapi/server.go#L281-L317","documentation":"readTimeRange failed to read the 8-byte minTimestamp (uint64) from the vmselect request stream. This is a wire-protocol read failure — the request was truncated or the stream errored — and the specific read error is wrapped in this message.","triggerScenarios":"A client sending a truncated vmselect request (fewer bytes than the protocol needs) so ctx.readUint64 hits EOF/short-read while decoding the time range in processTagValueSuffixes or processTenants.","commonSituations":"Buggy or mismatched client implementations of the vmselect protocol; connection closed early; proxies truncating request bodies.","solutions":["Verify the client sends the full request: tenant, time range (two uint64s), and remaining fields per protocol version","Check for version mismatch between client and vmselect wire formats","Inspect the wrapped error: io.EOF means the client closed early; fix the client-side writer","Capture a packet trace (tcpdump) to confirm truncation point"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// client-side: ensure the full request is written before reading the response\nvar buf bytes.Buffer\nbuf.Write(tenantBytes)\nbinary.Write(&buf, binary.BigEndian, uint64(minTS))\nbinary.Write(&buf, binary.BigEndian, uint64(maxTS))\nif n, err := conn.Write(buf.Bytes()); err != nil || n != buf.Len() {\n    return fmt.Errorf(\"incomplete vmselect request write: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"tr, err := ctx.readTimeRange()\nif err != nil {\n    return fmt.Errorf(\"bad request stream: %w\", err) // check wrapped EOF vs transport\n}","preventionTips":["Use the canonical VictoriaMetrics client code as protocol reference","Always flush/close the request writer fully before reading responses","Pin client/server versions to avoid protocol drift","Integration-test custom clients against a real vmselect"],"tags":["rpc","protocol","go","malformed-request"],"backgroundTag":"malformed-rpc-request","analyzedSha":"5079fb58f1e8e62113f90c945ad71586c797d770","analyzedAt":"2026-09-03T18:10:26.153Z","contentChangedAt":"2026-09-03T18:10:26.153Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}