{"record":{"id":"19983ef69687735f","repo":"gohugoio/hugo","slug":"must-not-provide-more-arguments-than-resource-obje-19983e","errorCode":null,"errorMessage":"must not provide more arguments than resource object and options","messagePattern":"must not provide more arguments than resource object and options","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/js/js.go","lineNumber":101,"sourceCode":"// Forward slashes in the ID is allowed.\nfunc (ns *Namespace) Batch(id string) (js.Batcher, error) {\n\tif err := esbuild.ValidateBatchID(id, true); err != nil {\n\t\treturn nil, err\n\t}\n\n\tb, err := ns.d.JSBatcherClient.Store().GetOrCreate(id, func() (js.Batcher, error) {\n\t\treturn ns.d.JSBatcherClient.New(id)\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn b, nil\n}\n\n// Babel processes the given Resource with Babel.\nfunc (ns *Namespace) Babel(args ...any) (resource.Resource, error) {\n\tif len(args) > 2 {\n\t\treturn nil, errors.New(\"must not provide more arguments than resource object and options\")\n\t}\n\n\tr, m, err := resourcehelpers.ResolveArgs(args)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar options babel.Options\n\tif m != nil {\n\t\toptions, err = babel.DecodeOptions(m)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn ns.babelClient.Process(r, options)\n}\n","sourceCodeStart":83,"sourceCodeEnd":118,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/tpl/js/js.go#L83-L118","documentation":"Thrown by js.Babel (tpl/js/js.go:101) when more than two arguments are passed. Babel accepts at most a resource object and an options map, so len(args) > 2 is rejected before ResolveArgs is even called. This mirrors the signature constraints of other resource-transform functions but is checked explicitly here.","triggerScenarios":"Calling {{ js.Babel $r $opts $extra }}, or accidentally passing a targetPath string plus a resource plus an options map (three positional args), which is the js.Build pattern but not valid for Babel.","commonSituations":"Confusing js.Babel's signature with js.Build (which supports a targetPath string first-arg form); copy-pasting a js.Build invocation and only swapping the function name; passing extra positional args meant as options.","solutions":["Pass at most two args: the resource and (optionally) one options map.","Move all configuration into a single dict: {{ js.Babel $r (dict \"sourceMap\" \"inline\" \"config\" \"babel.config.js\") }}.","If you need a target path, include it in the options map, not as a separate positional arg.","Switch to js.Build if you actually wanted the esbuild-based string-first-arg form."],"exampleFix":"// before\n{{ js.Babel $r \"app.js\" (dict \"sourceMap\" \"inline\") }}\n\n// after\n{{ js.Babel $r (dict \"targetPath\" \"app.js\" \"sourceMap\" \"inline\") }}","handlingStrategy":"validation","validationCode":"// Babel takes resource + one optional options map; do not pass a third arg:\n{{ $opts := dict \"sourceMap\" \"inline\" }}\n{{ js.Babel $r $opts }}","typeGuard":"// Go caller: enforce arg count before calling Babel:\nfunc validBabelArgs(args []any) bool { return len(args) <= 2 }","tryCatchPattern":null,"preventionTips":["Remember js.Babel accepts at most two args (resource + options).","Do not reuse the js.Build string-first-arg form with Babel.","Bundle all settings into a single options map."],"tags":["hugo","template","js","babel","argument-validation"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}