{"record":{"id":"9d65b1da121424c8","repo":"apache/beam","slug":"s-does-not-properly-override-extract-input-pvalues-returned","errorCode":null,"errorMessage":"%s does not properly override _extract_input_pvalues, returned %s from %s","messagePattern":"(.+?) does not properly override _extract_input_pvalues, returned (.+?) from (.+?)","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/pipeline.py","lineNumber":785,"sourceCode":"\n    if pvalueish is None:\n      full_label = self._current_transform().full_label\n      raise TypeCheckError(\n          f'Transform \"{full_label}\" was applied to the output of '\n          f'an object of type None.')\n\n    pvalueish, inputs = transform._extract_input_pvalues(pvalueish)\n    try:\n      if not isinstance(inputs, dict):\n        inputs = {str(ix): input for (ix, input) in enumerate(inputs)}\n    except TypeError:\n      raise NotImplementedError(\n          'Unable to extract PValue inputs from %s; either %s does not accept '\n          'inputs of this format, or it does not properly override '\n          '_extract_input_pvalues' % (pvalueish, transform))\n    for t, leaf_input in inputs.items():\n      if not isinstance(leaf_input, pvalue.PValue) or not isinstance(t, str):\n        raise NotImplementedError(\n            '%s does not properly override _extract_input_pvalues, '\n            'returned %s from %s' % (transform, inputs, pvalueish))\n\n    current = AppliedPTransform(\n        self._current_transform(),\n        transform,\n        full_label,\n        inputs,\n        None,\n        annotations=self._current_annotations())\n    self._current_transform().add_part(current)\n\n    try:\n      self.transforms_stack.append(current)\n\n      type_options = self._options.view_as(TypeOptions)\n      if type_options.pipeline_type_check:\n        transform.type_check_inputs(pvalueish)","sourceCodeStart":767,"sourceCodeEnd":803,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/pipeline.py#L767-L803","documentation":"After _extract_input_pvalues returns, Beam validates that every key is a str and every value is a PValue. A transform whose override returns anything else (wrong types, wrong container) triggers this NotImplementedError naming the transform, returned inputs, and original pvalueish.","triggerScenarios":"A custom PTransform overrides _extract_input_pvalues but returns non-string keys (e.g. int keys) or non-PValue leaves (raw data, None, nested lists) in the inputs mapping.","commonSituations":"Hand-written composite transforms with partial/incorrect _extract_input_pvalues implementations; returning the pvalueish itself when it contains non-PValue members; SDK changes tightening validation on previously-tolerated returns.","solutions":["Fix _extract_input_pvalues to return (pvalueish, {str_key: PValue_leaf, ...}).","Convert keys with str(...) and ensure every value is a PCollection/PValue instance.","Flatten nested containers into leaf PValues.","Check upstream for how the base PTransform implementation does it and mirror the contract."],"exampleFix":"// before\ndef _extract_input_pvalues(self, pvalueish):\n  return pvalueish, {0: pvalueish[0], 1: 'not a pvalue'}\n// after\ndef _extract_input_pvalues(self, pvalueish):\n  return pvalueish, {'a': pvalueish[0], 'b': pvalueish[1]}","handlingStrategy":"validation","validationCode":"from apache_beam.pvalue import PValue\ndef check_extract_result(inputs):\n    assert isinstance(inputs, dict), 'inputs must be dict'\n    for k, v in inputs.items():\n        assert isinstance(k, str) and isinstance(v, PValue), f'bad entry {k!r}: {type(v)}'","typeGuard":null,"tryCatchPattern":"try:\n    out = pipeline.apply(t, pvalueish)\nexcept NotImplementedError as e:\n    if 'properly override _extract_input_pvalues' in str(e):\n        raise ValueError(f'fix {t}._extract_input_pvalues return contract') from e","preventionTips":["Return (pvalueish, {str: PValue}) exactly from _extract_input_pvalues","Mirror base-class PTransform behavior","Add unit tests exercising the override"],"tags":["python","apache-beam","not-implemented","pvalue-input"],"backgroundTag":"method-not-implemented","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}