{"record":{"id":"87b4b998895216c7","repo":"gohugoio/hugo","slug":"too-many-padding-values-received-d-expected-max","errorCode":null,"errorMessage":"too many padding values: received %d, expected maximum of 4","messagePattern":"too many padding values: received (.+?), expected maximum of 4","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/images/filters.go","lineNumber":188,"sourceCode":"\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{\n\t\tOptions: newFilterOpts(_args...),\n\t\tFilter: paddingFilter{\n\t\t\ttop:    top,\n\t\t\tright:  right,\n\t\t\tbottom: bottom,\n\t\t\tleft:   left,\n\t\t\tccolor: ccolor,\n\t\t},\n\t}\n}\n\n// Dither creates a filter that dithers an image.\nfunc (*Filters) Dither(options ...any) gift.Filter {\n\tditherOptions := struct {\n\t\tColors     []any","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/images/filters.go#L170-L206","documentation":"Thrown by images.Padding when, after optionally consuming the trailing color, more than four numeric padding values remain (filters.go:187-189). The CSS shorthand supports at most top/right/bottom/left, so five numeric values are invalid.","triggerScenarios":"Effectively a defensive guard: the outer signature already caps total args at five, so reaching the default case requires five numeric values with none parsed as color. Triggered by passing five non-color arguments.","commonSituations":"Passing five pixel values, or a dynamically built slice that expands to five numbers.","solutions":["Limit padding values to at most four (top, right, bottom, left).","Use CSS shorthand: one value (all sides), two (vertical/horizontal), three (top/horizontal/bottom), or four (per side).","Validate the length of computed arg slices before passing them."],"exampleFix":"// before\n{{ $filters = $filters | append (images.Padding 1 2 3 4 5) }}\n// after\n{{ $filters = $filters | append (images.Padding 1 2 3 4) }}","handlingStrategy":"validation","validationCode":"{{ if gt (len $numericArgs) 4 }}{{ errorf \"too many padding values: %d\" (len $numericArgs) }}{{ end }}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Cap numeric padding values at four (CSS shorthand sides).","Build the slice deliberately, not by concatenating unknown inputs.","Map named sides (top/right/bottom/left) to a fixed four-element slice."],"tags":["image-filter","padding","validation","hugo"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}