{"record":{"id":"bcfc7f2e5c972985","repo":"hashicorp/nomad","slug":"s-must-be-a-int64-got-a-t-2-v","errorCode":null,"errorMessage":"%s must be a int64; got a (%T) %[2]v","messagePattern":"(.+?) must be a int64; got a \\(%T\\) %\\[2\\]v","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/var_put.go","lineNumber":532,"sourceCode":"\t\t\tvInt, ok := value.(int)\n\t\t\tif !ok {\n\t\t\t\treturn fmt.Errorf(\"%s must be integer; got (%T) %[2]v\", index, value)\n\t\t\t}\n\t\t\tidx := uint64(vInt)\n\t\t\tn := strings.ReplaceAll(\n\t\t\t\tcases.Title(language.English).String(\n\t\t\t\t\tstrings.ReplaceAll(index, \"_\", \" \"),\n\t\t\t\t), \" \", \"\")\n\t\t\tm[n] = idx\n\t\t\tdelete(m, index)\n\t\t}\n\t}\n\n\tfor _, index := range []string{\"create_time\", \"modify_time\"} {\n\t\tif value, ok := m[index]; ok {\n\t\t\tvInt, ok := value.(int)\n\t\t\tif !ok {\n\t\t\t\treturn fmt.Errorf(\"%s must be a int64; got a (%T) %[2]v\", index, value)\n\t\t\t}\n\t\t\tn := strings.ReplaceAll(\n\t\t\t\tcases.Title(language.English).String(\n\t\t\t\t\tstrings.ReplaceAll(index, \"_\", \" \"),\n\t\t\t\t), \" \", \"\")\n\t\t\tm[n] = vInt\n\t\t\tdelete(m, index)\n\t\t}\n\t}\n\n\t// Decode the rest\n\tif err := mapstructure.WeakDecode(m, result); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":514,"sourceCodeEnd":550,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/var_put.go#L514-L550","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)."],"exampleFix":"// before\ncreate_time = \"2024-01-01T00:00:00Z\"\n// after\ncreate_time = 1704067200000000000","handlingStrategy":"validation","validationCode":"# strip server-managed time fields from the spec before submitting\ngrep -E '^(create_time|modify_time)\\s*=' spec.hcl && { echo 'remove create_time/modify_time from spec' >&2; exit 1; } || true","typeGuard":null,"tryCatchPattern":"if err := run(); err != nil && strings.Contains(err.Error(), \"must be a int64\") {\n    log.Fatalf(\"spec time field wrong type: %v\", err)\n}","preventionTips":["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."],"tags":["hcl","nomad","type-mismatch","validation"],"backgroundTag":"type-mismatch","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"}