hashicorp/nomad · error
error parsing limit: %v
Error message
error parsing limit: %v
What it means
This error is returned by the agent's FileReadAt HTTP endpoint (command/agent/fs_endpoint.go:157) when the `limit` query parameter is present but cannot be parsed as a base-10 int64 via strconv.ParseInt. The limit caps how many bytes of file content are read. It wraps the underlying strconv error and rejects the request before the filesystem RPC is made.
Source
Thrown at command/agent/fs_endpoint.go:157
var err error
q := req.URL.Query()
if allocID = strings.TrimPrefix(req.URL.Path, "/v1/client/fs/readat/"); allocID == "" {
return nil, allocIDNotPresentErr
}
if path = q.Get("path"); path == "" {
return nil, fileNameNotPresentErr
}
if offset, err = strconv.ParseInt(q.Get("offset"), 10, 64); err != nil {
return nil, fmt.Errorf("error parsing offset: %v", err)
}
// Parse the limit
if limitStr := q.Get("limit"); limitStr != "" {
if limit, err = strconv.ParseInt(limitStr, 10, 64); err != nil {
return nil, fmt.Errorf("error parsing limit: %v", err)
}
}
// Create the request arguments
fsReq := &cstructs.FsStreamRequest{
AllocID: allocID,
Path: path,
Offset: offset,
Origin: "start",
Limit: limit,
PlainText: true,
}
s.parse(resp, req, &fsReq.QueryOptions.Region, &fsReq.QueryOptions)
// Make the request
return s.fsStreamImpl(resp, req, "FileSystem.Stream", fsReq, fsReq.AllocID)
}
View on GitHub (pinned to 482b49bf1a)
Solutions
- Pass limit as a plain base-10 integer string, e.g. limit=32768 (no decimals, units, or exponents).
- Validate the value with strconv.ParseInt(s, 10, 64) client-side before sending.
- Omit the parameter entirely — it is only parsed when non-empty.
- Clamp computed byte counts to math.MaxInt64 before formatting.
Example fix
// before curl "http://localhost:4646/v1/client/fs/readat?alloc_id=abc&path=/logs/app.log&limit=1.5MB" // after curl "http://localhost:4646/v1/client/fs/readat?alloc_id=abc&path=/logs/app.log&limit=1500000"
Defensive patterns
Strategy: validation
Validate before calling
limit := q.Get("limit")
if limit != "" {
if _, err := strconv.ParseInt(limit, 10, 64); err != nil {
return fmt.Errorf("invalid limit %q: must be a base-10 int64", limit)
}
} Type guard
func validLimit(s string) bool {
if s == "" { return true }
_, err := strconv.ParseInt(s, 10, 64)
return err == nil
} Try / catch
res, err := fs.ReadAt(allocID, path, offset, limit)
if err != nil {
if strings.Contains(err.Error(), "error parsing limit") {
// fall back: omit the limit parameter
res, err = fs.ReadAt(allocID, path, offset, "")
}
} Prevention
- Format limits with strconv.FormatInt, never float formatting.
- Validate query params with ParseInt before sending.
- Omit empty optional parameters instead of sending empty strings.
- Clamp computed byte counts to math.MaxInt64.
When it happens
Trigger: Calling GET /v1/client/fs/readat?alloc_id=<id>&path=<path>&limit=<v> where v is non-empty and not a plain int64: limit=abc, limit=1.5, limit=1e6, limit=10KB, or a value exceeding int64 range.
Common situations: Hand-built curl requests with unit suffixes; SDKs stringifying floats or computed sizes; shell variables expanding empty/whitespace; JSON number formatting like 1e6 leaking into query strings.
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.
Related errors
- failed to parse follow field to boolean: %v
- users: unable to parse uid/gid from username
- <combined HCL diagnostics from str.String()>
- Unable to convert Uid to an int: %w
- Unable to convert Gid to an int: %w
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/840bd4fa6a445675.
Report an issue: GitHub.