{"record":{"id":"42afd708076d079a","repo":"gohugoio/hugo","slug":"padding-values-must-not-exceed-5000-pixels","errorCode":null,"errorMessage":"padding values must not exceed 5000 pixels","messagePattern":"padding values must not exceed 5000 pixels","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/images/filters.go","lineNumber":173,"sourceCode":"\n\t_args := args // preserve original args for most stable hash\n\n\tif vcs, ok, err := toColorGo(args[len(args)-1]); ok || err != nil {\n\t\tif err != nil {\n\t\t\tpanic(\"invalid canvas color: specify RGB or RGBA using hex notation\")\n\t\t}\n\t\tccolor = vcs\n\t\targs = args[:len(args)-1]\n\t\tif len(args) == 0 {\n\t\t\tpanic(\"not enough arguments: provide one or more padding values using the CSS shorthand property syntax\")\n\t\t}\n\t}\n\n\tvar vals []int\n\tfor _, v := range args {\n\t\tvi := cast.ToInt(v)\n\t\tif vi > 5000 {\n\t\t\tpanic(\"padding values must not exceed 5000 pixels\")\n\t\t}\n\t\tvals = append(vals, vi)\n\t}\n\n\tswitch len(args) {\n\tcase 1:\n\t\ttop, right, bottom, left = vals[0], vals[0], vals[0], vals[0]\n\tcase 2:\n\t\ttop, right, bottom, left = vals[0], vals[1], vals[0], vals[1]\n\tcase 3:\n\t\ttop, right, bottom, left = vals[0], vals[1], vals[2], vals[1]\n\tcase 4:\n\t\ttop, right, bottom, left = vals[0], vals[1], vals[2], vals[3]\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"too many padding values: received %d, expected maximum of 4\", len(args)))\n\t}\n\n\treturn filter{","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/images/filters.go#L155-L191","documentation":"Thrown by images.Padding when any individual padding value exceeds 5000 pixels (filters.go:170-174). The cap guards against accidentally generating enormous canvases that would exhaust memory.","triggerScenarios":"Passing a padding value greater than 5000, e.g. images.Padding 9999. Each value is checked after cast.ToInt conversion.","commonSituations":"Unit confusion (using a multiplier), copy-paste of a large dimension, or a template variable holding an unintended large number.","solutions":["Reduce each padding value to 5000 or fewer pixels.","Double-check the source of dynamic padding values (e.g. multiplied dimensions).","If you genuinely need a larger canvas, reconsider whether padding is the right tool."],"exampleFix":"// before\n{{ $filters = $filters | append (images.Padding 20000) }}\n// after\n{{ $filters = $filters | append (images.Padding 2000) }}","handlingStrategy":"validation","validationCode":"{{ range $v := .paddings }}\n  {{ if gt (int $v) 5000 }}{{ errorf \"padding %v exceeds 5000px\" $v }}{{ end }}\n{{ end }}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Clamp computed padding values to <= 5000.","Review multipliers feeding padding numbers.","Prefer moderate padding; very large canvases waste memory."],"tags":["image-filter","padding","limits","validation","hugo"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}