{"record":{"id":"0a005f8a40a08c18","repo":"hashicorp/nomad","slug":"last-contact-duration-is-out-of-range-d","errorCode":null,"errorMessage":"Last contact duration is out of range: %d","messagePattern":"Last contact duration is out of range: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"api/api.go","lineNumber":1197,"sourceCode":"\n// parseQueryMeta is used to help parse query meta-data\nfunc parseQueryMeta(resp *http.Response, q *QueryMeta) error {\n\theader := resp.Header\n\n\t// Parse the X-Nomad-Index\n\tindex, err := strconv.ParseUint(header.Get(\"X-Nomad-Index\"), 10, 64)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to parse X-Nomad-Index: %v\", err)\n\t}\n\tq.LastIndex = index\n\n\t// Parse the X-Nomad-LastContact\n\tlast, err := strconv.ParseUint(header.Get(\"X-Nomad-LastContact\"), 10, 64)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to parse X-Nomad-LastContact: %v\", err)\n\t}\n\tif last > math.MaxInt64 {\n\t\treturn fmt.Errorf(\"Last contact duration is out of range: %d\", last)\n\t}\n\tq.LastContact = time.Duration(last) * time.Millisecond\n\tq.NextToken = header.Get(\"X-Nomad-NextToken\")\n\n\t// Parse the X-Nomad-KnownLeader\n\tswitch header.Get(\"X-Nomad-KnownLeader\") {\n\tcase \"true\":\n\t\tq.KnownLeader = true\n\tdefault:\n\t\tq.KnownLeader = false\n\t}\n\treturn nil\n}\n\n// parseWriteMeta is used to help parse write meta-data\nfunc parseWriteMeta(resp *http.Response, q *WriteMeta) error {\n\theader := resp.Header\n","sourceCodeStart":1179,"sourceCodeEnd":1215,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/api/api.go#L1179-L1215","documentation":"After parsing X-Nomad-LastContact as uint64 milliseconds, parseQueryMeta guards against values exceeding math.MaxInt64, which cannot be safely represented as a signed time.Duration. The server sent a LastContact value too large to store, so the client rejects it.","triggerScenarios":"A Nomad server (or malformed/mocked response) returns an X-Nomad-LastContact value greater than math.MaxInt64 (9223372036854775807) milliseconds, e.g. a corrupted or fabricated header.","commonSituations":"Malicious or misbehaving intermediary injecting oversized headers; bugs in custom Nomad forks or mocks returning sentinel values like 18446744073709551615.","solutions":["Inspect the raw response header value and correct the source of the oversized value","Fix any mock/test server to return realistic millisecond durations","Restart/redeploy the Nomad server if it is emitting corrupt timing values"],"exampleFix":"// before (mock server)\nw.Header().Set(\"X-Nomad-LastContact\", \"18446744073709551615\")\n// after\nw.Header().Set(\"X-Nomad-LastContact\", \"500\")","handlingStrategy":"validation","validationCode":"if v, err := strconv.ParseUint(resp.Header.Get(\"X-Nomad-LastContact\"), 10, 64); err == nil && v > math.MaxInt64 {\n    return fmt.Errorf(\"X-Nomad-LastContact %d exceeds MaxInt64\", v)\n}","typeGuard":"func lastContactInRange(h http.Header) bool {\n    v, err := strconv.ParseUint(h.Get(\"X-Nomad-LastContact\"), 10, 64)\n    return err == nil && v <= math.MaxInt64\n}","tryCatchPattern":null,"preventionTips":["Keep mock/test servers returning realistic millisecond values","Reject oversized header values at the proxy layer","Audit middleware that rewrites X-Nomad-* headers"],"tags":["http-header","overflow","parsing"],"backgroundTag":"duration-overflow","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}