{"record":{"id":"4dbdd187b9266015","repo":"hashicorp/nomad","slug":"failed-to-parse-value-of-q-v-as-a-uint64-v","errorCode":null,"errorMessage":"Failed to parse value of %q (%v) as a uint64: %v","messagePattern":"Failed to parse value of %q \\((.+?)\\) as a uint64: (.+?)","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"command/agent/job_endpoint.go","lineNumber":776,"sourceCode":"\tdiffsStr := req.URL.Query().Get(\"diffs\")\n\tdiffTagName := req.URL.Query().Get(\"diff_tag\")\n\tdiffVersion := req.URL.Query().Get(\"diff_version\")\n\n\tvar diffsBool bool\n\tif diffsStr != \"\" {\n\t\tvar err error\n\t\tdiffsBool, err = strconv.ParseBool(diffsStr)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"Failed to parse value of %q (%v) as a bool: %v\", \"diffs\", diffsStr, err)\n\t\t}\n\t}\n\n\tvar diffVersionInt *uint64\n\n\tif diffVersion != \"\" {\n\t\tparsedDiffVersion, err := strconv.ParseUint(diffVersion, 10, 64)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"Failed to parse value of %q (%v) as a uint64: %v\", \"diff_version\", diffVersion, err)\n\t\t}\n\t\tdiffVersionInt = &parsedDiffVersion\n\t}\n\n\targs := structs.JobVersionsRequest{\n\t\tJobID:       jobID,\n\t\tDiffs:       diffsBool,\n\t\tDiffVersion: diffVersionInt,\n\t\tDiffTagName: diffTagName,\n\t}\n\tif s.parse(resp, req, &args.Region, &args.QueryOptions) {\n\t\treturn nil, nil\n\t}\n\n\tvar out structs.JobVersionsResponse\n\tif err := s.agent.RPC(\"Job.GetJobVersions\", &args, &out); err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":758,"sourceCodeEnd":794,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/agent/job_endpoint.go#L758-L794","documentation":"jobVersions (command/agent/job_endpoint.go:776) parses the ?diff_version= query parameter with strconv.ParseUint(diffVersion, 10, 64). If the value is not a valid unsigned base-10 integer (or exceeds uint64), the request fails with 'Failed to parse value of \"diff_version\" (...) as a uint64'. The version-history request is rejected before any diff is computed.","triggerScenarios":"GET /v1/job/<job-id>/versions?diff_version=<bad value> — e.g. diff_version=latest, diff_version=-1, diff_version=3.0, diff_version=0x10, or a number larger than 18446744073709551615.","commonSituations":"Passing the word 'latest' or 'current' instead of a numeric version; negative numbers (job versions are unsigned); decimal points or hex notation; scripts interpolating 'none' when no version is selected.","solutions":["Send a plain base-10 unsigned integer, e.g. diff_version=4.","Remove diff_version to compare against the default (no pinned version).","Clamp/negative-check values in client code — version indexes are uint64 and cannot be negative.","Use the %v value in the error message to identify exactly what string arrived."],"exampleFix":"// before\nurl := \"/v1/job/web/versions?diff_version=latest\"\n// after\nurl := fmt.Sprintf(\"/v1/job/web/versions?diff_version=%d\", 4)","handlingStrategy":"validation","validationCode":"// Before GET versions with diff_version\nif dv != \"\" {\n    if _, err := strconv.ParseUint(dv, 10, 64); err != nil {\n        return fmt.Errorf(\"diff_version must be a uint64, got %q\", dv)\n    }\n}","typeGuard":"func isUint64(s string) bool {\n    _, err := strconv.ParseUint(s, 10, 64)\n    return err == nil\n}","tryCatchPattern":"resp, err := http.Get(versionsURL+\"?diff_version=\"+dv)\nif err != nil { return err }\nif resp.StatusCode == 400 {\n    // 'Failed to parse value of \"diff_version\" ... as a uint64'\n    return fmt.Errorf(\"diff_version must be a non-negative integer: %s\", dv)\n}","preventionTips":["Never send 'latest'/'-1'/'3.0'; resolve to a concrete non-negative integer first.","Remember job version indexes are unsigned — negatives always fail.","Format with %d from a uint64 variable.","Omit diff_version when no specific version is targeted."],"tags":["http","query-parameter","uint64","parsing","nomad"],"backgroundTag":"invalid-query-parameter","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"}