{"id":"c63e920577bb4a84","repo":"gohugoio/hugo","slug":"invalid-options-type-w","errorCode":null,"errorMessage":"invalid options type: %w","messagePattern":"invalid options type: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/internal/resourcehelpers/helpers.go","lineNumber":65,"sourceCode":"\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\n}\n","sourceCodeStart":47,"sourceCodeEnd":70,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/tpl/internal/resourcehelpers/helpers.go#L47-L70","documentation":"In the two-argument form of a resource transformation, the resource was valid but the first argument (the options) could not be converted to map[string]any by hmaps.ToStringMapE. Hugo wraps the underlying conversion error with %w. Options for transforms like PostCSS, Babel, ToCSS, and Fingerprint variants must be a dict/map.","triggerScenarios":"`{{ $r | resources.PostCSS \"config.js\" }}` or any transform given a string/slice/number as options instead of a dict, so ToStringMapE fails on the non-map type.","commonSituations":"Passing a config file path or preset name as a bare string where a dict is required; passing `slice` instead of `dict`; options built in a partial arriving as the wrong type.","solutions":["Wrap options in a dict: `{{ $r | resources.PostCSS (dict \"config\" \"config.js\") }}`.","Check the specific transform's docs for its option keys (e.g. toCSS: targetPath, transpiler, vars).","If building options dynamically, verify with `printf \"%T\"` that it is a map before passing."],"exampleFix":"<!-- before -->\n{{ $css := $scss | toCSS \"main.css\" }}\n<!-- after -->\n{{ $css := $scss | toCSS (dict \"targetPath\" \"main.css\") }}","handlingStrategy":"validation","validationCode":"{{ $opts := dict \"targetPath\" \"css/main.css\" \"outputStyle\" \"compressed\" }}\n{{ $css := $scss | css.Sass $opts }}","typeGuard":"{{/* options must be a map/dict, not a string or slice */}}","tryCatchPattern":null,"preventionTips":["Build transformation options with dict, never a bare string or slice","Check the docs for each transformation's supported option keys — unknown shapes fail to decode","Keep option values simple scalars/maps that map cleanly to the documented option struct"],"tags":["hugo","templates","hugo-pipes","resources","options"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}