hashicorp/nomad · error
%s must be a int64; got a (%T) %[2]v
Error message
%s must be a int64; got a (%T) %[2]v
What it means
Same mapping path as the index check but for the `create_time`/`modify_time` keys: these must decode as Go ints (int64 timestamps) in the HCL spec. If supplied as any other type the function returns `%s must be a int64; got a (%T) %v`, naming the key and the actual type/value.
Source
Thrown at command/var_put.go:532
vInt, ok := value.(int)
if !ok {
return fmt.Errorf("%s must be integer; got (%T) %[2]v", index, value)
}
idx := uint64(vInt)
n := strings.ReplaceAll(
cases.Title(language.English).String(
strings.ReplaceAll(index, "_", " "),
), " ", "")
m[n] = idx
delete(m, index)
}
}
for _, index := range []string{"create_time", "modify_time"} {
if value, ok := m[index]; ok {
vInt, ok := value.(int)
if !ok {
return fmt.Errorf("%s must be a int64; got a (%T) %[2]v", index, value)
}
n := strings.ReplaceAll(
cases.Title(language.English).String(
strings.ReplaceAll(index, "_", " "),
), " ", "")
m[n] = vInt
delete(m, index)
}
}
// Decode the rest
if err := mapstructure.WeakDecode(m, result); err != nil {
return err
}
return nil
}
View on GitHub (pinned to 482b49bf1a)
Solutions
- Remove `create_time`/`modify_time` from the spec — the server sets these automatically.
- If required, supply integer nanosecond timestamps without quotes: `create_time = 1704067200000000000`.
- Start from a `nomad var init` template and include only user-managed fields (path, items).
Example fix
// before create_time = "2024-01-01T00:00:00Z" // after create_time = 1704067200000000000
Defensive patterns
Strategy: validation
Validate before calling
# strip server-managed time fields from the spec before submitting
grep -E '^(create_time|modify_time)\s*=' spec.hcl && { echo 'remove create_time/modify_time from spec' >&2; exit 1; } || true Try / catch
if err := run(); err != nil && strings.Contains(err.Error(), "must be a int64") {
log.Fatalf("spec time field wrong type: %v", err)
} Prevention
- Omit create_time/modify_time from specs — the server sets them.
- If kept, use integer nanosecond timestamps without quotes.
- Avoid converting JSON API output directly into editable specs.
When it happens
Trigger: An .hcl spec containing `create_time = "2024-01-01"` or a float/string where an integer nanosecond timestamp is expected — usually from hand-editing or converting `nomad var read` JSON output where times are large integers.
Common situations: Pasting human-readable timestamps into specs; converting JSON API output to HCL where the time fields got stringified; leaving server-managed fields in a spec meant only for creating/updating.
Related errors
- %s must be integer; got (%T) %[2]v
- <combined HCL diagnostics from str.String()>
- invalid variables limit: %v
- invalid capacity: %v
- invalid capacity_min: %v
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/bcfc7f2e5c972985.
Report an issue: GitHub.