{"record":{"id":"4af21681b918ce46","repo":"keras-team/keras","slug":"error-preamble-for-layer-class-name-receive-4af216","errorCode":null,"errorMessage":"{error_preamble} For layer '{class_name}', received `{method_name}()` argument `{name}`, but `call()` does not have argument `{expected_call_arg}`.","messagePattern":"(.+?) For layer '(.+?)', received `(.+?)\\(\\)` argument `(.+?)`, but `call\\(\\)` does not have argument `(.+?)`\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/layer.py","lineNumber":2063,"sourceCode":"\n    # Multiple args: check that all names line up.\n    kwargs = {}\n    for name in expected_names:\n        method_name = target_fn.__name__\n        error_preamble = (\n            f\"For a `{method_name}()` method with more than one argument, all \"\n            \"arguments should have a `_shape` suffix and match an argument \"\n            f\"from `call()`. E.g. `{method_name}(self, foo_shape, bar_shape)` \"\n        )\n        if not name.endswith(\"_shape\"):\n            raise ValueError(\n                f\"{error_preamble} For layer '{class_name}', \"\n                f\"Received `{method_name}()` argument \"\n                f\"`{name}`, which does not end in `_shape`.\"\n            )\n        expected_call_arg = utils.removesuffix(name, \"_shape\")\n        if expected_call_arg not in call_spec.arguments_dict:\n            raise ValueError(\n                f\"{error_preamble} For layer '{class_name}', \"\n                f\"received `{method_name}()` argument \"\n                f\"`{name}`, but `call()` does not have argument \"\n                f\"`{expected_call_arg}`.\"\n            )\n        if name in shapes_dict:\n            kwargs[name] = shapes_dict[name]\n\n    return kwargs\n\n\nclass CallContext:\n    def __init__(self, entry_layer):\n        self.entry_layer = entry_layer\n\n    def get_value(self, arg_name, default=None):\n        \"\"\"Get the context value for `arg_name`, or `default` if unset.\"\"\"\n        return getattr(self, arg_name, default)","sourceCodeStart":2045,"sourceCodeEnd":2081,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/layer.py#L2045-L2081","documentation":"Keras maps each <name>_shape parameter of build/compute_output_shape to a call() argument named <name> by stripping the _shape suffix. This error fires when the stripped name has no matching parameter in the layer's call() signature, so the shape value has nowhere to be applied.","triggerScenarios":"Defining compute_output_shape(self, input_shape, aux_shape) when call(self, inputs) has no aux parameter; renaming a call() argument without updating compute_output_shape; leftover *_shape params after refactoring.","commonSituations":"Copy-pasting a compute_output_shape override from another layer whose call() signature differs; version upgrades where call() signatures changed; stale overrides after deleting a call() argument.","solutions":["Add the matching argument to call(): def call(self, inputs, aux) so aux_shape maps to aux","Remove the orphaned *_shape parameter from build/compute_output_shape","Keep the two signatures in sync: for every extra call() argument, accept <arg>_shape in build/compute_output_shape"],"exampleFix":"# before\nclass MyLayer(keras.layers.Layer):\n    def call(self, inputs):\n        ...\n    def compute_output_shape(self, input_shape, aux_shape):\n        ...  # ValueError\n\n# after\nclass MyLayer(keras.layers.Layer):\n    def call(self, inputs, aux=None):\n        ...\n    def compute_output_shape(self, input_shape, aux_shape=None):\n        ...","handlingStrategy":"validation","validationCode":"import inspect\ncall_args = set(inspect.signature(MyLayer.call).parameters) - {'self'}\nshape_args = {p.removesuffix('_shape') for p in inspect.signature(MyLayer.compute_output_shape).parameters if p != 'self'}\nassert shape_args <= call_args, shape_args - call_args","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep call() and compute_output_shape/build signatures synchronized","Update *_shape parameters whenever renaming call() arguments","Add a CI signature-consistency check for custom layers"],"tags":["keras","shape-inference","signature-mismatch"],"backgroundTag":"shape-inference-contract","analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}