hashicorp/nomad · error
Failed to parse value of %q (%v) as a uint64: %v
Error message
Failed to parse value of %q (%v) as a uint64: %v
What it means
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.
Source
Thrown at command/agent/job_endpoint.go:776
diffsStr := req.URL.Query().Get("diffs")
diffTagName := req.URL.Query().Get("diff_tag")
diffVersion := req.URL.Query().Get("diff_version")
var diffsBool bool
if diffsStr != "" {
var err error
diffsBool, err = strconv.ParseBool(diffsStr)
if err != nil {
return nil, fmt.Errorf("Failed to parse value of %q (%v) as a bool: %v", "diffs", diffsStr, err)
}
}
var diffVersionInt *uint64
if diffVersion != "" {
parsedDiffVersion, err := strconv.ParseUint(diffVersion, 10, 64)
if err != nil {
return nil, fmt.Errorf("Failed to parse value of %q (%v) as a uint64: %v", "diff_version", diffVersion, err)
}
diffVersionInt = &parsedDiffVersion
}
args := structs.JobVersionsRequest{
JobID: jobID,
Diffs: diffsBool,
DiffVersion: diffVersionInt,
DiffTagName: diffTagName,
}
if s.parse(resp, req, &args.Region, &args.QueryOptions) {
return nil, nil
}
var out structs.JobVersionsResponse
if err := s.agent.RPC("Job.GetJobVersions", &args, &out); err != nil {
return nil, err
}View on GitHub (pinned to 482b49bf1a)
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.
Example fix
// before
url := "/v1/job/web/versions?diff_version=latest"
// after
url := fmt.Sprintf("/v1/job/web/versions?diff_version=%d", 4) Defensive patterns
Strategy: validation
Validate before calling
// Before GET versions with diff_version
if dv != "" {
if _, err := strconv.ParseUint(dv, 10, 64); err != nil {
return fmt.Errorf("diff_version must be a uint64, got %q", dv)
}
} Type guard
func isUint64(s string) bool {
_, err := strconv.ParseUint(s, 10, 64)
return err == nil
} Try / catch
resp, err := http.Get(versionsURL+"?diff_version="+dv)
if err != nil { return err }
if resp.StatusCode == 400 {
// 'Failed to parse value of "diff_version" ... as a uint64'
return fmt.Errorf("diff_version must be a non-negative integer: %s", dv)
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Invalid query parameter" / "Failed to parse value of ...": fixing bad query string parameters across APIs — this error's family across 36 libraries.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Failed to parse value of %q (%v) as a bool: %v
- Failed to parse value of %q (%v) as a int: %v
- tty value is not a boolean: %v
- Failed to parse value of %q (%v) as a bool: %v
- Failed to parse value of %qq (%v) as a bool: %v
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/4dbdd187b9266015.
Report an issue: GitHub.