{"record":{"id":"d7f6eb48f50392f6","repo":"gohugoio/hugo","slug":"requires-numeric-arguments","errorCode":null,"errorMessage":"requires numeric arguments","messagePattern":"requires numeric arguments","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/math/math.go","lineNumber":92,"sourceCode":"\t\treturn 0, errors.New(\"requires a numeric argument\")\n\t}\n\treturn math.Asin(af), nil\n}\n\n// Atan returns the arctangent, in radians, of n.\nfunc (ns *Namespace) Atan(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.Atan(af), nil\n}\n\n// Atan2 returns the arc tangent of n/m, using the signs of the two to determine the quadrant of the return value.\nfunc (ns *Namespace) Atan2(n, m any) (float64, error) {\n\tafx, err := cast.ToFloat64E(n)\n\tif err != nil {\n\t\treturn 0, errors.New(\"requires numeric arguments\")\n\t}\n\tafy, err := cast.ToFloat64E(m)\n\tif err != nil {\n\t\treturn 0, errors.New(\"requires numeric arguments\")\n\t}\n\treturn math.Atan2(afx, afy), nil\n}\n\n// Ceil returns the least integer value greater than or equal to n.\nfunc (ns *Namespace) Ceil(n any) (float64, error) {\n\txf, err := cast.ToFloat64E(n)\n\tif err != nil {\n\t\treturn 0, errors.New(\"Ceil operator can't be used with non-float value\")\n\t}\n\n\treturn math.Ceil(xf), nil\n}\n","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/tpl/math/math.go#L74-L110","documentation":"Thrown by math.Atan2 (tpl/math/math.go:92) when the FIRST argument (n) cannot be converted to float64. Atan2 takes two operands and computes atan2(n, m); the message uses the plural 'arguments' but the line corresponds to the n conversion failing.","triggerScenarios":"Calling {{ math.Atan2 .Y .X }} where .Y (the first arg) is non-numeric; passing a text/nil/bool value as the first operand.","commonSituations":"Wrong argument order (passing a non-numeric field first); nil param; type drift in source data.","solutions":["Ensure the first argument is numeric (it represents the y-coordinate in atan2(y, x)).","Add a numeric default to the first arg.","Verify argument order matches atan2(y, x) convention.","Fix the source field to be numeric."],"exampleFix":"// before\n{{ math.Atan2 .Params.yLabel .Params.x }}\n\n// after\n{{ $y := .Params.y | default 0 }}\n{{ $x := .Params.x | default 1 }}\n{{ math.Atan2 $y $x }}","handlingStrategy":"type-guard","validationCode":"// Validate the FIRST (y) operand before math.Atan2(y, x):\n{{ $y := .Param \"y\" | default 0 }}\n{{ $x := .Param \"x\" | default 1 }}\n{{ math.Atan2 $y $x }}","typeGuard":"// Reuse the isNumeric guard from errorIndex 148 on the first argument of math.Atan2.","tryCatchPattern":null,"preventionTips":["Ensure the first arg of math.Atan2 is numeric.","Mind the atan2(y, x) argument order.","Default unset params to numbers."],"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"}