{"record":{"id":"82de7a7c8ad45ae4","repo":"apache/beam","slug":"row-key-s-not-found-in-input-pcollection","errorCode":null,"errorMessage":"row_key %s not found in input PCollection.","messagePattern":"row_key (.+?) not found in input PCollection\\.","errorType":"exception","errorClass":"KeyError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/transforms/enrichment_handlers/bigtable.py","lineNumber":147,"sourceCode":"          response_dict[cf_id] = {}\n          for col_id, col_v in cf_v.items():\n            if self._include_timestamp:\n              response_dict[cf_id][col_id.decode(self._encoding)] = [\n                  (v.value.decode(self._encoding), v.timestamp) for v in col_v\n              ]\n            else:\n              response_dict[cf_id][col_id.decode(\n                  self._encoding)] = col_v[0].value.decode(self._encoding)\n      elif self._exception_level == ExceptionLevel.WARN:\n        _LOGGER.warning(\n            'no matching row found for row_key: %s '\n            'with row_filter: %s' % (row_key_str, self._row_filter))\n      elif self._exception_level == ExceptionLevel.RAISE:\n        raise ValueError(\n            'no matching row found for row_key: %s '\n            'with row_filter=%s' % (row_key_str, self._row_filter))\n    except KeyError:\n      raise KeyError('row_key %s not found in input PCollection.' % row_key_str)\n    except NotFound:\n      raise NotFound(\n          'GCP BigTable cluster `%s:%s:%s` not found.' %\n          (self._project_id, self._instance_id, self._table_id))\n    except Exception as e:\n      raise e\n\n    return request, beam.Row(**response_dict)\n\n  def __exit__(self, exc_type, exc_val, exc_tb):\n    \"\"\"Clean the instantiated BigTable client.\"\"\"\n    self.client = None\n    self.instance = None\n    self._table = None\n\n  def get_cache_key(self, request: beam.Row) -> str:\n    \"\"\"Returns a string formatted with row key since it is unique to\n    a request made to `Bigtable`.\"\"\"","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/transforms/enrichment_handlers/bigtable.py#L129-L165","documentation":"The BigTable enrichment handler wraps a KeyError from looking up the requested row key and re-raises it with a clear message: the row_key value used for the lookup was not found in the input PCollection's fields. This typically means the enrichment input row lacks the field named by row_key (or the field value is missing), so the key extraction failed before BigTable was even queried.","triggerScenarios":"Using enrichment_handlers.BigTableEnrichmentHandler where the input Beam.Row does not contain the configured row_key field, or row_key_str is absent/None so response_dict key access raises KeyError.","commonSituations":"Renaming columns upstream without updating the handler's row_key config; events that optionally lack the key field; typos in field names.","solutions":["Ensure every input row has a non-null field matching the handler's row_key name","Update the handler's row_key configuration to the correct column name","Add a validation/filter transform before enrichment to drop or repair rows missing the key"],"exampleFix":"// before\nBigTableEnrichmentHandler(row_key='user_id', ...)\n# input rows only have 'userId'\n// after\nBigTableEnrichmentHandler(row_key='userId', ...)\n# or: beam.Map(lambda r: r | {'userId': r['user_id']}) first","handlingStrategy":"validation","validationCode":"def row_has_key(row, key):\n    return key in row._asdict() and row._asdict()[key] is not None\n# assert all(row_has_key(r, 'userId') for r in rows) before enriching","typeGuard":null,"tryCatchPattern":"try:\n    enriched = beam_rows | beam.transforms.enrichment.Enrichment(handler)\nexcept KeyError as e:\n    if 'row_key' in str(e):\n        raise ValueError('input rows missing configured row_key field') from e\n    raise","preventionTips":["Keep row_key config in sync with upstream column names","Add a pre-enrichment validation transform for required fields","Avoid renaming fields without updating enrichment handlers"],"tags":["python","apache-beam","bigtable","enrichment"],"backgroundTag":"resource-not-found","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"}