{"record":{"id":"9652eccb10dbc100","repo":"keras-team/keras","slug":"must-specify-exactly-two-of-left-padding-right-pa","errorCode":null,"errorMessage":"Must specify exactly two of left_padding, right_padding, target_width. Received: left_padding={left_padding}, right_padding={right_padding}, target_width={target_width}","messagePattern":"Must specify exactly two of left_padding, right_padding, target_width\\. Received: left_padding=(.+?), right_padding=(.+?), target_width=(.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/ops/image.py","lineNumber":1556,"sourceCode":"\ndef _validate_pad_images_args(\n    top_padding,\n    left_padding,\n    bottom_padding,\n    right_padding,\n    target_height,\n    target_width,\n):\n    if [top_padding, bottom_padding, target_height].count(None) != 1:\n        raise ValueError(\n            \"Must specify exactly two of \"\n            \"top_padding, bottom_padding, target_height. \"\n            f\"Received: top_padding={top_padding}, \"\n            f\"bottom_padding={bottom_padding}, \"\n            f\"target_height={target_height}\"\n        )\n    if [left_padding, right_padding, target_width].count(None) != 1:\n        raise ValueError(\n            \"Must specify exactly two of \"\n            \"left_padding, right_padding, target_width. \"\n            f\"Received: left_padding={left_padding}, \"\n            f\"right_padding={right_padding}, \"\n            f\"target_width={target_width}\"\n        )\n\n    _validate_non_negative(top_padding, \"top_padding\")\n    _validate_non_negative(bottom_padding, \"bottom_padding\")\n    _validate_non_negative(target_height, \"target_height\")\n    _validate_non_negative(left_padding, \"left_padding\")\n    _validate_non_negative(right_padding, \"right_padding\")\n    _validate_non_negative(target_width, \"target_width\")\n\n\ndef _validate_crop_images_args(\n    top_cropping,\n    left_cropping,","sourceCodeStart":1538,"sourceCodeEnd":1574,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/ops/image.py#L1538-L1574","documentation":"Horizontal counterpart of the pad_images triple rule: exactly two of left_padding, right_padding, target_width must be specified; otherwise the width is over- or under-determined and the validator raises.","triggerScenarios":"pad_images where the height triple is fine but width has 0, 1, or 3 specified values, e.g. only target_width=224 given.","commonSituations":"Asymmetric configs copied from a symmetric example; forgetting the second width argument when pad-to-target width; YAML keys typos (e.g. width_padding) silently leaving values None.","solutions":["Give exactly two of the three: e.g. target_width=224, right_padding=4","Symmetric case: left_padding=p, right_padding=p","Check both axes independently — height passing does not imply width is valid"],"exampleFix":"# before\nout = pad_images(img, target_width=224)\n\n# after\nout = pad_images(img, target_width=224, right_padding=0)","handlingStrategy":"validation","validationCode":"assert [left_padding, right_padding, target_width].count(None) == 1","typeGuard":"def width_triple_ok(l, r, tw) -> bool:\n    return [l, r, tw].count(None) == 1","tryCatchPattern":null,"preventionTips":["Check width independently of height","Lint config keys against the expected exactly-two rule"],"tags":["keras","image","padding","argument-validation"],"backgroundTag":"missing-or-conflicting-arguments","analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}