{"record":{"id":"586a7b9fe911d738","repo":"keras-team/keras","slug":"the-lists-inputs-and-mask-should-have-the-same-586a7b","errorCode":null,"errorMessage":"The lists `inputs` and `mask` should have the same length. Received: inputs={inputs} of length {len(inputs)}, and mask={mask} of length {len(mask)}","messagePattern":"The lists `inputs` and `mask` should have the same length\\. Received: inputs=(.+?) of length (.+?), and mask=(.+?) of length (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/merging/concatenate.py","lineNumber":132,"sourceCode":"\n        for shape in input_shapes[1:]:\n            if output_shape[self.axis] is None or shape[self.axis] is None:\n                output_shape[self.axis] = None\n                break\n            output_shape[self.axis] += shape[self.axis]\n        return tuple(output_shape)\n\n    def compute_mask(self, inputs, mask=None):\n        if mask is None:\n            return None\n        if not isinstance(mask, (tuple, list)):\n            raise ValueError(f\"`mask` should be a list. Received mask={mask}\")\n        if not isinstance(inputs, (tuple, list)):\n            raise ValueError(\n                f\"`inputs` should be a list. Received: inputs={inputs}\"\n            )\n        if len(mask) != len(inputs):\n            raise ValueError(\n                \"The lists `inputs` and `mask` should have the same length. \"\n                f\"Received: inputs={inputs} of length {len(inputs)}, and \"\n                f\"mask={mask} of length {len(mask)}\"\n            )\n        if all(m is None for m in mask):\n            return None\n        # Make a list of masks while making sure\n        # the dimensionality of each mask\n        # is the same as the corresponding input.\n        masks = []\n        for input_i, mask_i in zip(inputs, mask):\n            if mask_i is None:\n                # Input is unmasked. Append all 1s to masks,\n                masks.append(ops.ones_like(input_i, dtype=\"bool\"))\n            elif mask_i.ndim < input_i.ndim:\n                # Broadcast mask shape to match in a way where we capture the\n                # input as a symbolic input in the op graph.\n                mask_i = ops.logical_or(","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/merging/concatenate.py#L114-L150","documentation":"Concatenate.compute_mask requires len(mask) == len(inputs) so it can align each mask with its input. This error fires when the mask list length differs from the number of input tensors.","triggerScenarios":"Concatenate()([x1, x2, x3], mask=[m1, m2]); omitting None placeholders for unmasked inputs.","commonSituations":"Adding an input to the concat but not the mask list; mixed masked/unmasked inputs; refactoring input arity.","solutions":["Provide exactly one mask entry per input, using None where absent: mask=[m1, None, m2]","Regenerate mask lists whenever the input list changes","Prefer automatic mask propagation over manual mask plumbing"],"exampleFix":"# before\nout = concat([x1, x2, x3], mask=[m1, m2])\n\n# after\nout = concat([x1, x2, x3], mask=[m1, None, m2])","handlingStrategy":"validation","validationCode":"assert isinstance(mask, (list, tuple)) and len(mask) == len(inputs)","typeGuard":"def masks_match_inputs(mask, inputs) -> bool:\n    return mask is None or (isinstance(mask, (list, tuple)) and len(mask) == len(inputs))","tryCatchPattern":null,"preventionTips":["Emit one mask entry per input","Use None placeholders for unmasked inputs"],"tags":["keras","concatenate","masking","length-mismatch"],"backgroundTag":"mask-length-mismatch","analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}