{"record":{"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/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/tpl/internal/resourcehelpers/helpers.go#L32-L68","documentation":"A resource transformation template function (css.Sass, js.Build, minify, etc.) received a single argument that does not implement resources.ResourceTransformer. In ResolveArgs the len(args)==1 branch type-asserts args[0] and reports its concrete type when the assertion fails. See helpers.go:47-52.","triggerScenarios":"{{ css.Sass \"main.scss\" }} passing a plain string, or {{ (nil) | css.Sass }} where resources.Get returned nil because the asset was not found.","commonSituations":"resources.Get/GetRemote returned nil (missing file) and nil is piped into a transform; passing a URL or filename string instead of the Resource object.","solutions":["Ensure the value passed is a Hugo Resource obtained via resources.Get, resources.GetRemote, or resources.FromString.","Guard against nil using {{ with $r }}...{{ end }} before transforming.","Confirm the source asset exists under the assets mount or the remote fetch succeeded."],"exampleFix":"// before\n{{ $css := css.Sass \"main.scss\" }}\n\n// after\n{{ $r := resources.Get \"main.scss\" }}\n{{ with $r }}{{ $css := $r | css.Sass }}{{ end }}","handlingStrategy":"type-guard","validationCode":"// In Go: ensure the value satisfies the interface before transforming.\nfunc isResourceTransformer(v any) bool {\n    _, ok := v.(resources.ResourceTransformer)\n    return ok\n}","typeGuard":"// In templates: guard nil/non-resources before transforming.\n{{ with $r := resources.Get \"main.scss\" }}\n  {{ $r | css.Sass }}\n{{ else }}\n  {{ warnf \"resource not found\" }}\n{{ end }}","tryCatchPattern":null,"preventionTips":["Always pipe a Resource object, never a filename string.","Use {{ with }} to guard nil resource lookups before any transform."],"tags":["hugo","resource","pipeline","template","type-error"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}