{"record":{"id":"0154e9f75001cd4d","repo":"gohugoio/hugo","slug":"requires-a-numeric-argument","errorCode":null,"errorMessage":"requires a numeric argument","messagePattern":"requires a numeric argument","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/math/math.go","lineNumber":60,"sourceCode":"type Namespace struct {\n\td *deps.Deps\n}\n\n// Abs returns the absolute value of n.\nfunc (ns *Namespace) Abs(n any) (float64, error) {\n\taf, err := cast.ToFloat64E(n)\n\tif err != nil {\n\t\treturn 0, errors.New(\"the math.Abs function requires a numeric argument\")\n\t}\n\n\treturn math.Abs(af), nil\n}\n\n// Acos returns the arccosine, in radians, of n.\nfunc (ns *Namespace) Acos(n any) (float64, error) {\n\taf, err := cast.ToFloat64E(n)\n\tif err != nil {\n\t\treturn 0, errors.New(\"requires a numeric argument\")\n\t}\n\treturn math.Acos(af), nil\n}\n\n// Add adds the multivalued addends n1 and n2 or more values.\nfunc (ns *Namespace) Add(inputs ...any) (any, error) {\n\treturn ns.doArithmetic(inputs, '+')\n}\n\n// Asin returns the arcsine, in radians, of n.\nfunc (ns *Namespace) Asin(n any) (float64, error) {\n\taf, err := cast.ToFloat64E(n)\n\tif err != nil {\n\t\treturn 0, errors.New(\"requires a numeric argument\")\n\t}\n\treturn math.Asin(af), nil\n}\n","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/tpl/math/math.go#L42-L78","documentation":"Thrown by math.Acos (tpl/math/math.go:60) when its argument cannot be converted to float64. Acos computes the arccosine in radians and requires a numeric input; any non-numeric value (non-numeric string, nil, bool, struct, slice) triggers this generic numeric-argument error.","triggerScenarios":"Calling {{ math.Acos .Value }} where .Value is a non-numeric string, nil, bool, or aggregate type; piping a text field into the trig function.","commonSituations":"Using a template field that holds text instead of a number; nil from an unset param; assuming a quoted numeric string auto-converts when it does not.","solutions":["Pass a numeric value (int or float) to math.Acos.","Add a numeric default: {{ math.Acos (.Param \"x\" | default 0) }}.","Guard the call behind a type/numeric check on the source value.","Fix the source field to be numeric."],"exampleFix":"// before\n{{ math.Acos .Params.angle }}\n\n// after\n{{ $a := .Params.angle | default 0 }}\n{{ math.Acos $a }}","handlingStrategy":"type-guard","validationCode":"// Validate numeric input before math.Acos:\n{{ $v := .Param \"x\" | default 0 }}\n{{ math.Acos $v }}","typeGuard":"// See errorIndex 148 for isNumeric; reuse it before calling math.Acos.","tryCatchPattern":null,"preventionTips":["Pass numeric values to trig functions.","Default unset params to a number.","Keep source numeric fields unquoted."],"tags":["hugo","template","math","type-validation","trigonometry"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}