{"record":{"id":"cd2c347f28043650","repo":"gohugoio/hugo","slug":"expected-slice-of-resource-objects-received-t-in","errorCode":null,"errorMessage":"expected slice of Resource objects, received %T instead","messagePattern":"expected slice of Resource objects, received %T instead","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/resources/resources.go","lineNumber":218,"sourceCode":"}\n\n// Concat concatenates a slice of Resource objects. These resources must\n// (currently) be of the same Media Type.\nfunc (ns *Namespace) Concat(targetPathIn any, r any) (resource.Resource, error) {\n\ttargetPath, err := cast.ToStringE(targetPathIn)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar rr resource.Resources\n\n\tswitch v := r.(type) {\n\tcase resource.Resources:\n\t\trr = v\n\tcase resource.ResourcesConverter:\n\t\trr = v.ToResources()\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"expected slice of Resource objects, received %T instead\", r)\n\t}\n\n\tif len(rr) == 0 {\n\t\treturn nil, errors.New(\"must provide one or more Resource objects to concat\")\n\t}\n\n\treturn ns.bundlerClient.Concat(targetPath, rr)\n}\n\n// FromString creates a Resource from a string published to the relative target path.\nfunc (ns *Namespace) FromString(targetPathIn, contentIn any) (resource.Resource, error) {\n\ttargetPath, err := cast.ToStringE(targetPathIn)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tcontent, err := cast.ToStringE(contentIn)\n\tif err != nil {\n\t\treturn nil, err","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/tpl/resources/resources.go#L200-L236","documentation":"Thrown by resources.Concat when the second argument is neither a resource.Resources slice nor a resource.ResourcesConverter. The type switch has only those two cases plus the default that errors, printing the actual Go type via %T.","triggerScenarios":"Calling {{ $r := resources.Concat \"out.js\" (slice $a $b) }} where the second arg is a single Resource, a []any of resources, a string, or any non-converter value.","commonSituations":"Passing a single resource instead of a slice, passing a plain Go []any/slice (which is not typed as resource.Resources), or passing the result of a function that returns resource.Resource rather than resource.Resources.","solutions":["Pass a resource.Resources slice; build one with (slice $r1 $r2) where each element is a Resource.","If you have a single resource, wrap it: (slice $r).","Ensure the slice elements are actual Resource objects returned by resources.Get/Match/etc.","Check the %T in the message to see the concrete type you actually passed."],"exampleFix":"// before (single resource, not a slice):\n{{ $out := resources.Concat \"app.js\" $js }}\n// after:\n{{ $out := resources.Concat \"app.js\" (slice $js) }}","handlingStrategy":"type-guard","validationCode":"{{ $slice := slice }}\n{{ range $r := $candidates }}{{ $slice = $slice | append $r }}{{ end }}\n{{ $out := resources.Concat \"out.js\" $slice }}","typeGuard":"// Hugo template: ensure each element is a Resource before appending.\n{{ $ok := true }}\n{{ range $r := $candidates }}{{ if not $r.Params }}{{ $ok = false }}{{ end }}{{ end }}","tryCatchPattern":null,"preventionTips":["Always pass a resource.Resources slice (built via slice/append), not a single Resource.","Confirm slice elements come from resources.Get/Match/GetRemote.","Use the %T message to diagnose the actual type passed."],"tags":["resources","concat","type-error","template"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}