{"id":"8186449286300458","repo":"gohugoio/hugo","slug":"must-provide-an-url-and-optionally-an-options-map","errorCode":null,"errorMessage":"must provide an URL and optionally an options map","messagePattern":"must provide an URL and optionally an options map","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/resources/resources.go","lineNumber":113,"sourceCode":"\tr, err := ns.createClient.Get(filenamestr)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn r\n}\n\n// GetRemote gets the URL (via HTTP(s)) in the first argument in args and creates Resource object that can be used for\n// further transformations.\n//\n// A second argument may be provided with an option map.\n//\n// Note: This method does not return any error as a second return value,\n// for any error situations the error can be checked in .Err.\nfunc (ns *Namespace) GetRemote(args ...any) (resource.Resource, error) {\n\tget := func(args ...any) (resource.Resource, error) {\n\t\tif len(args) < 1 || len(args) > 2 {\n\t\t\treturn nil, errors.New(\"must provide an URL and optionally an options map\")\n\t\t}\n\n\t\turlstr, err := cast.ToStringE(args[0])\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tvar options map[string]any\n\n\t\tif len(args) > 1 {\n\t\t\toptions, err = hmaps.ToStringMapE(args[1])\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\n\t\treturn ns.createClient.FromRemote(urlstr, options)\n\t}","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/tpl/resources/resources.go#L95-L131","documentation":"`resources.GetRemote` accepts exactly one required argument (the URL string) and one optional options map; any other argument count fails validation. Because GetRemote reports failures through the resource's `.Err` rather than halting the build, this error arrives wrapped in a resource error you must check.","triggerScenarios":"Calling `{{ resources.GetRemote }}` with zero arguments or with three or more, e.g. passing headers and method as separate arguments instead of inside one options dict: `resources.GetRemote $url $headers $method`.","commonSituations":"Migrating from getJSON/getCSV call styles that took multiple URL parts; splitting request options into separate template arguments instead of a single `dict`; templating errors where a pipeline unexpectedly yields extra values.","solutions":["Call with the URL and, optionally, one options dict: `resources.GetRemote $url (dict \"headers\" (dict \"Authorization\" $t))`.","Combine method/body/headers into that single options map rather than separate arguments.","Always check `.Err` on the returned resource, since GetRemote surfaces failures there."],"exampleFix":"<!-- before -->\n{{ $r := resources.GetRemote $url $headers \"GET\" }}\n<!-- after -->\n{{ $r := resources.GetRemote $url (dict \"headers\" $headers \"method\" \"GET\") }}","handlingStrategy":"validation","validationCode":"{{ $url := \"https://example.org/data.json\" }}{{ with resources.GetRemote $url (dict \"headers\" (dict)) }}...{{ end }}","typeGuard":"{{ $ok := and (eq (printf \"%T\" $url) \"string\") (or (not $opts) (reflect.IsMap $opts)) }}","tryCatchPattern":"{{ with try (resources.GetRemote $url $opts) }}{{ with .Err }}{{ warnf \"GetRemote failed: %s\" . }}{{ end }}{{ end }}","preventionTips":["Call resources.GetRemote with a string URL and at most one options map","Build options with dict, not a slice or scalar","Don't pass extra positional arguments — bundle everything into the options map"],"tags":["hugo","resources","get-remote","arguments"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}