{"record":{"id":"b64f0fa22c2dc30a","repo":"gohugoio/hugo","slug":"not-enough-arguments-provide-one-or-more-padding","errorCode":null,"errorMessage":"not enough arguments: provide one or more padding values using the CSS shorthand property syntax","messagePattern":"not enough arguments: provide one or more padding values using the CSS shorthand property syntax","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/images/filters.go","lineNumber":165,"sourceCode":"// signature is images.Padding V1 [V2] [V3] [V4] [COLOR].\nfunc (*Filters) Padding(args ...any) gift.Filter {\n\tif len(args) < 1 || len(args) > 5 {\n\t\tpanic(\"the padding filter requires between 1 and 5 arguments\")\n\t}\n\n\tvar top, right, bottom, left int\n\tvar ccolor color.Color = color.White // canvas color\n\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:","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/images/filters.go#L147-L183","documentation":"Thrown by images.Padding when the only argument supplied is consumed as the canvas color, leaving zero padding values (filters.go:163-166). Padding requires at least one pixel value; a lone color is not enough.","triggerScenarios":"Calling images.Padding with exactly one argument that is a valid color, e.g. images.Padding \"#ffffff\". The color is consumed and no padding values remain.","commonSituations":"Developer intends to pad with defaults and just names the color, not realizing pixel values are mandatory; or a template conditionally omits the numeric padding when a color is present.","solutions":["Always include at least one pixel value before the optional color.","Reorder so the color is the trailing argument and pixels precede it.","If you want default white padding, pass the pixel values explicitly (color defaults to white when omitted)."],"exampleFix":"// before\n{{ $filters = $filters | append (images.Padding \"#ffffff\") }}\n// after\n{{ $filters = $filters | append (images.Padding 10 \"#ffffff\") }}","handlingStrategy":"validation","validationCode":"{{ if and (eq (len $args) 1) (reflect.IsMap (index $args 0)) }}\n  {{ errorf \"Padding needs at least one pixel value\" }}\n{{ end }}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass at least one numeric pixel value.","Treat the color as an optional trailing argument, never the sole one.","Default the color (white) by omitting it rather than passing it alone."],"tags":["image-filter","padding","validation","hugo"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}