{"id":"104d69fb1a6987aa","repo":"gohugoio/hugo","slug":"type-t-not-supported-in-resource-transformations","errorCode":null,"errorMessage":"type %T not supported in Resource transformations","messagePattern":"type %T not supported in Resource transformations","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/internal/resourcehelpers/helpers.go","lineNumber":50,"sourceCode":"\tv1, ok1 := args[0].(string)\n\tif !ok1 {\n\t\treturn nil, \"\", false\n\t}\n\tv2, ok2 := args[1].(resources.ResourceTransformer)\n\n\treturn v2, v1, ok2\n}\n\n// This roundabout way of doing it is needed to get both pipeline behavior and options as arguments.\nfunc ResolveArgs(args []any) (resources.ResourceTransformer, map[string]any, error) {\n\tif len(args) == 0 {\n\t\treturn nil, nil, errors.New(\"no Resource provided in transformation\")\n\t}\n\n\tif len(args) == 1 {\n\t\tr, ok := args[0].(resources.ResourceTransformer)\n\t\tif !ok {\n\t\t\treturn nil, nil, fmt.Errorf(\"type %T not supported in Resource transformations\", args[0])\n\t\t}\n\t\treturn r, nil, nil\n\t}\n\n\tr, ok := args[1].(resources.ResourceTransformer)\n\tif !ok {\n\t\tif _, ok := args[1].(map[string]any); !ok {\n\t\t\treturn nil, nil, fmt.Errorf(\"no Resource provided in transformation\")\n\t\t}\n\t\treturn nil, nil, fmt.Errorf(\"type %T not supported in Resource transformations\", args[0])\n\t}\n\n\tm, err := hmaps.ToStringMapE(args[0])\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"invalid options type: %w\", err)\n\t}\n\n\treturn r, m, nil","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/tpl/internal/resourcehelpers/helpers.go#L32-L68","documentation":"A single argument was passed to a resource transformation but it does not implement resources.ResourceTransformer — the interface all pipeable Hugo assets satisfy. The %T verb reports the actual concrete type so the author can see what was piped in instead of a resource. It also fires in the two-arg path when args[1] is a plain map (options in the resource slot).","triggerScenarios":"`{{ \"css/main.css\" | minify }}` (a string, not a resource); piping a Page, nil, or plain map into fingerprint/minify/toCSS; passing options where the resource should be.","commonSituations":"Confusing a file path string with a resource (must call resources.Get first); piping the result of readFile (a string) into a transform; page resources fetched with the wrong method returning a different type.","solutions":["Fetch a real resource first: `{{ $r := resources.Get \"css/main.css\" }}{{ $r | minify }}`.","Check argument order for two-arg transforms: options first, resource last (`resources.PostCSS $opts $r` or `$r | resources.PostCSS $opts`).","Print the offending type with `printf \"%T\"` to see what you actually passed."],"exampleFix":"<!-- before -->\n{{ $min := \"css/main.css\" | minify }}\n<!-- after -->\n{{ $min := resources.Get \"css/main.css\" | minify }}","handlingStrategy":"type-guard","validationCode":"{{ $r := resources.Get \"data.json\" }}\n{{ if $r }}{{ $min := $r | minify }}{{ end }}","typeGuard":"{{/* ensure the value is a Resource, not a string path or Page */}}\n{{ if reflect.IsMap $r }}{{ errorf \"expected a Resource, got a map\" }}{{ end }}","tryCatchPattern":null,"preventionTips":["Pass an actual Resource object, not a URL string or file path, to fingerprint/minify/toCSS etc.","Fetch remote assets with resources.GetRemote first, then transform the returned resource","Don't pass Pages or plain strings into resource transformation pipelines"],"tags":["hugo","templates","hugo-pipes","resources","type-mismatch"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}