{"id":"490244e80710e3e0","repo":"gohugoio/hugo","slug":"must-not-provide-more-arguments-than-resource-and","errorCode":null,"errorMessage":"must not provide more arguments than Resource and hash algorithm","messagePattern":"must not provide more arguments than Resource and hash algorithm","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/resources/resources.go","lineNumber":267,"sourceCode":"\tdata := args[1]\n\n\tr, ok := args[2].(resources.ResourceTransformer)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"type %T not supported in Resource transformations\", args[2])\n\t}\n\n\treturn ns.templatesClient.ExecuteAsTemplate(ctx, r, targetPath, data)\n}\n\n// Fingerprint transforms the given Resource with a MD5 hash of the content in\n// the RelPermalink and Permalink.\nfunc (ns *Namespace) Fingerprint(args ...any) (resource.Resource, error) {\n\tif len(args) < 1 {\n\t\treturn nil, errors.New(\"must provide a Resource object\")\n\t}\n\n\tif len(args) > 2 {\n\t\treturn nil, errors.New(\"must not provide more arguments than Resource and hash algorithm\")\n\t}\n\n\tvar algo string\n\tresIdx := 0\n\n\tif len(args) == 2 {\n\t\tresIdx = 1\n\t\tvar err error\n\t\talgo, err = cast.ToStringE(args[0])\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tr, ok := args[resIdx].(resources.ResourceTransformer)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"%T can not be transformed\", args[resIdx])\n\t}","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/tpl/resources/resources.go#L249-L285","documentation":"Hugo's `resources.Fingerprint` template function accepts at most two arguments: an optional hash-algorithm string and a Resource object. When called with three or more arguments (len(args) > 2), it returns this error before any processing. The variadic signature exists to support both `resources.Fingerprint $res` and `resources.Fingerprint \"sha512\" $res` call forms.","triggerScenarios":"Calling `{{ resources.Fingerprint \"sha256\" $res \"extra\" }}` or piping while also passing two leading args, e.g. `{{ $res | fingerprint \"sha512\" \"md5\" }}` — anything that resolves to more than two total arguments to Fingerprint.","commonSituations":"Confusing argument order with other resource functions, passing options maps like js.Build/Babel accept (Fingerprint takes none), or accidentally duplicating the algorithm when converting between pipe and direct call syntax in templates copied from docs or themes.","solutions":["Reduce the call to at most two arguments: `{{ $fp := resources.Fingerprint $res }}` or `{{ $fp := resources.Fingerprint \"sha512\" $res }}`.","With pipes, pass only the algorithm before the pipe: `{{ $res | fingerprint \"sha512\" }}.","Remove any options map — Fingerprint only accepts an algorithm string (md5, sha256, sha384, sha512)."],"exampleFix":"<!-- before -->\n{{ $fp := resources.Fingerprint \"sha512\" $css \"integrity\" }}\n<!-- after -->\n{{ $fp := resources.Fingerprint \"sha512\" $css }}","handlingStrategy":"validation","validationCode":"{{/* pass at most (Resource, algo) — build args explicitly, never splat */}}\n{{ $r := resources.Get \"img.png\" }}\n{{ $fp := $r | fingerprint \"sha256\" }}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Call fingerprint with at most two args: the resource and an optional hash algorithm (md5, sha256, sha384, sha512)","When piping (`$r | fingerprint`), remember the piped resource counts as the final argument — pass only the algorithm before the pipe","Audit partials that forward `args...` to resource functions for accidental extra parameters"],"tags":["hugo","templates","resources","fingerprint","arguments"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}