{"record":{"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/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/tpl/internal/resourcehelpers/helpers.go#L47-L70","documentation":"In the two-argument form, the first argument (treated as the options map) could not be converted to map[string]any by hmaps.ToStringMapE. The wrapped error (%w) explains the conversion failure. See helpers.go:63-66.","triggerScenarios":"Passing an int, struct, slice, or other non-map value as the options argument, e.g. {{ $r | css.Sass 42 }}.","commonSituations":"Typo passing the wrong variable as options; a typed config struct that ToStringMapE cannot coerce; treating a positional arg as options when it should be the resource.","solutions":["Pass options as a map (dict in templates) or an object convertible to map[string]any.","Check the type of the options variable before calling.","Omit the options argument entirely when no options are needed (use the 1-arg form)."],"exampleFix":"// before\n{{ $r | css.Sass 42 }}\n\n// after\n{{ $r | css.Sass (dict \"outputStyle\" \"compressed\") }}","handlingStrategy":"validation","validationCode":"// Ensure the options argument is a map[string]any (or convertible) before passing.\nm, err := hmaps.ToStringMapE(options)\nif err != nil {\n    return fmt.Errorf(\"options must be a map: %w\", err)\n}","typeGuard":"func isOptionsMap(v any) bool {\n    switch v.(type) {\n    case map[string]any, map[string]interface{}: return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Pass options as a dict in templates or map[string]any in Go.","Omit the options argument entirely when none are needed."],"tags":["hugo","resource","pipeline","template","options","type-error"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}