{"record":{"id":"a449182c6cda46d5","repo":"gohugoio/hugo","slug":"ceil-operator-can-t-be-used-with-non-float-value","errorCode":null,"errorMessage":"Ceil operator can't be used with non-float value","messagePattern":"Ceil operator can't be used with non-float value","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/math/math.go","lineNumber":105,"sourceCode":"\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\n// Cos returns the cosine of the radian argument n.\nfunc (ns *Namespace) Cos(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.Cos(af), nil\n}\n\n// Div divides n1 by n2.\nfunc (ns *Namespace) Div(inputs ...any) (any, error) {\n\treturn ns.doArithmetic(inputs, '/')\n}","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/tpl/math/math.go#L87-L123","documentation":"Thrown by math.Ceil (tpl/math/math.go:105) when its argument cannot be converted to float64. Ceil returns the least integer >= n and needs a float; cast.ToFloat64E failing produces this Ceil-specific message.","triggerScenarios":"Calling {{ math.Ceil .Value }} with a non-numeric string, nil, bool, struct, or slice.","commonSituations":"Unset param (nil); text field where a number was expected; quoted numeric string that fails conversion.","solutions":["Pass a numeric value to math.Ceil.","Add a numeric default: {{ math.Ceil (.Param \"n\" | default 0) }}.","Guard behind a numeric check on the source value.","Fix the source data so the field is numeric."],"exampleFix":"// before\n{{ math.Ceil .Params.count }}\n\n// after\n{{ $n := .Params.count | default 0 }}\n{{ math.Ceil $n }}","handlingStrategy":"type-guard","validationCode":"// Validate numeric input before math.Ceil:\n{{ $v := .Param \"n\" | default 0 }}\n{{ math.Ceil $v }}","typeGuard":"// Reuse the isNumeric guard from errorIndex 148 before calling math.Ceil.","tryCatchPattern":null,"preventionTips":["Pass numeric values to math.Ceil.","Default unset params to a number.","Keep source numeric fields unquoted."],"tags":["hugo","template","math","type-validation","rounding"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}