{"record":{"id":"dd6b6a29a979bf11","repo":"hashicorp/packer","slug":"too-many-values-1-needed-v","errorCode":null,"errorMessage":"too many values, 1 needed: %v","messagePattern":"too many values, 1 needed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"hcl2template/function/datetime.go","lineNumber":55,"sourceCode":"// using RFC 3339 \"Date and Time format\" syntax, and so timestamp returns a\n// string in this format.\nfunc Timestamp() (cty.Value, error) {\n\treturn TimestampFunc.Call([]cty.Value{})\n}\n\n// LegacyIsotimeFunc constructs a function that returns a string representation\n// of the current date and time using the Go language datetime formatting syntax.\nvar LegacyIsotimeFunc = function.New(&function.Spec{\n\tParams: []function.Parameter{},\n\tVarParam: &function.Parameter{\n\t\tName: \"format\",\n\t\tType: cty.String,\n\t},\n\tType:         function.StaticReturnType(cty.String),\n\tRefineResult: refineNotNull,\n\tImpl: func(args []cty.Value, retType cty.Type) (cty.Value, error) {\n\t\tif len(args) > 1 {\n\t\t\treturn cty.StringVal(\"\"), fmt.Errorf(\"too many values, 1 needed: %v\", args)\n\t\t}\n\t\tif len(args) == 0 {\n\t\t\treturn cty.StringVal(initTime.Format(time.RFC3339)), nil\n\t\t}\n\t\tformat := args[0].AsString()\n\t\treturn cty.StringVal(initTime.Format(format)), nil\n\t},\n})\n\n// LegacyStrftimeFunc constructs a function that returns a string representation\n// of the current date and time using the Go language strftime datetime formatting syntax.\nvar LegacyStrftimeFunc = function.New(&function.Spec{\n\tParams: []function.Parameter{},\n\tVarParam: &function.Parameter{\n\t\tName: \"format\",\n\t\tType: cty.String,\n\t},\n\tType:         function.StaticReturnType(cty.String),","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/hcl2template/function/datetime.go#L37-L73","documentation":"The `timestamp()` HCL2 function takes at most one optional argument (a Go time layout string). The cty function framework already enforces arity via VarParam, but this defensive check in the Impl returns this error if more than one argument reaches it, echoing the offending values.","triggerScenarios":"Calling `timestamp(a, b)` in an HCL2 template — e.g. `timestamp(\"2006-01-02\", \"extra\")` — if arity checking is bypassed or the check is the active guard against extra args.","commonSituations":"Copy-pasting a strftime-style call with two arguments, or misremembering that timestamp accepts a format plus something else; normally caught earlier by HCL arity validation.","solutions":["Pass at most one argument: `timestamp()` for RFC3339 now, or `timestamp(\"2006-01-02T15:04:05Z07:00\")` for a custom Go layout","Split formatting: use `timestamp()` and format downstream if you need multiple pieces of data","Remove extra arguments in the template"],"exampleFix":"// before (invalid)\ntimestamp = timestamp(\"2006-01-02\", \"UTC\")\n// after\ntimestamp = timestamp(\"2006-01-02\")","handlingStrategy":"validation","validationCode":"// check arity before use (HCL has no guard; validate via packer console)\n// $ packer console\n// > timestamp()\n// > timestamp(\"2006-01-02\")","typeGuard":null,"tryCatchPattern":"null","preventionTips":["Remember timestamp() accepts 0 or 1 argument only","Use Go reference-time layouts: \"2006-01-02T15:04:05Z07:00\"","Validate templates with `packer console` or `packer validate` before builds"],"tags":["hcl2","function","timestamp","arity"],"backgroundTag":"function-arity-mismatch","analyzedSha":"eb36e3c3e48a036f3e8cc94087636ee72e1303c9","analyzedAt":"2026-09-05T13:20:43.127Z","contentChangedAt":"2026-09-05T13:20:43.127Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}