{"id":"e4b32b43c396ef51","repo":"gohugoio/hugo","slug":"there-is-no-such-an-operation","errorCode":null,"errorMessage":"there is no such an operation","messagePattern":"there is no such an operation","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/math/math.go","lineNumber":131,"sourceCode":"\t\treturn au - bu, nil\n\tcase '*':\n\t\tif isInt {\n\t\t\treturn ai * bi, nil\n\t\t} else if isFloat {\n\t\t\treturn af * bf, nil\n\t\t}\n\t\treturn au * bu, nil\n\tcase '/':\n\t\tif isInt && bi != 0 {\n\t\t\treturn ai / bi, nil\n\t\t} else if isFloat && bf != 0 {\n\t\t\treturn af / bf, nil\n\t\t} else if isUint && bu != 0 {\n\t\t\treturn au / bu, nil\n\t\t}\n\t\treturn nil, errors.New(\"can't divide the value by 0\")\n\tdefault:\n\t\treturn nil, errors.New(\"there is no such an operation\")\n\t}\n}\n","sourceCodeStart":113,"sourceCodeEnd":134,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/common/math/math.go#L113-L134","documentation":"DoArithmetic accepts an operator as a rune and only implements '+', '-', '*', and '/'. Any other rune reaches the default case at common/math/math.go:131 and returns this error. In practice user templates can't pass arbitrary operators (add/sub/mul/div hardcode them), so this surfaces mainly from internal or programmatic callers passing an unsupported op.","triggerScenarios":"Calling common/math.DoArithmetic (directly from Go code, a fork, or a custom build) with an op rune other than '+', '-', '*', '/' — e.g. '%' for modulo or '^' for power.","commonSituations":"Custom Hugo forks or Go code reusing the math package and expecting modulo/power support; modulo in templates must use the separate `mod`/`math.Mod` functions, not DoArithmetic.","solutions":["Use one of the supported operators: '+', '-', '*', '/'.","For modulo in templates use `mod`/`math.Mod`; for powers use `math.Pow` — DoArithmetic does not implement them.","If extending Hugo, add the operator case to the switch in DoArithmetic rather than passing an unhandled rune."],"exampleFix":"// before\nres, err := math.DoArithmetic(a, b, '%')\n// after\nres, err := math.DoArithmetic(a, b, '/') // or use the dedicated mod helpers","handlingStrategy":"validation","validationCode":"validOps := map[rune]bool{'+': true, '-': true, '*': true, '/': true}\nif !validOps[op] { /* reject before calling */ }","typeGuard":null,"tryCatchPattern":"v, err := math.DoArithmetic(a, b, op)\nif err != nil {\n\t// unknown operator: programming error — fail fast, fix the call site\n}","preventionTips":["Pass only the supported operator runes '+', '-', '*', '/'.","If operators come from config or user input, whitelist them at the trust boundary.","Prefer the named template funcs (add, sub, mul, div) over building operator characters dynamically."],"tags":["hugo","math","internal-api","unsupported-operation"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}