{"record":{"id":"0bc83206b4258316","repo":"apache/beam","slug":"error-trying-to-access-nonexistent-attribute-key-in-write","errorCode":null,"errorMessage":"Error trying to access nonexistent attribute `{key}` in write result. Please see __documentation__ for available attributes.","messagePattern":"Error trying to access nonexistent attribute `(.+?)` in write result\\. Please see __documentation__ for available attributes\\.","errorType":"exception","errorClass":"AttributeError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/io/gcp/bigquery.py","lineNumber":2697,"sourceCode":"\n    Returns:\n      A PCollection of rows that failed when inserting to BigQuery,\n      along with their errors.\n\n    Raises:\n      AttributeError: if accessed with a write method\n      besides ``[STREAMING_INSERTS, STORAGE_WRITE_API]``.\"\"\"\n    self.validate([\n        WriteToBigQuery.Method.STREAMING_INSERTS,\n        WriteToBigQuery.Method.STORAGE_WRITE_API\n    ],\n                  'FAILED_ROWS_WITH_ERRORS')\n\n    return self._failed_rows_with_errors\n\n  def __getitem__(self, key):\n    if key not in self.attributes:\n      raise AttributeError(\n          f'Error trying to access nonexistent attribute `{key}` in write '\n          'result. Please see __documentation__ for available attributes.')\n\n    return self.attributes[key].__get__(self, WriteResult)\n\n\nclass StorageWriteToBigQuery(PTransform):\n  \"\"\"Writes data to BigQuery using Storage API.\n  Supports dynamic destinations. Dynamic schemas are not supported yet.\n\n  Experimental; no backwards compatibility guarantees.\n  \"\"\"\n  IDENTIFIER = \"beam:schematransform:org.apache.beam:bigquery_storage_write:v2\"\n  FAILED_ROWS = \"FailedRows\"\n  FAILED_ROWS_WITH_ERRORS = \"FailedRowsWithErrors\"\n  # fields for rows sent to Storage API with dynamic destinations\n  DESTINATION = \"destination\"\n  RECORD = \"record\"","sourceCodeStart":2679,"sourceCodeEnd":2715,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/io/gcp/bigquery.py#L2679-L2715","documentation":"WriteResult.__getitem__ raises AttributeError when indexing with a key that is not in self.attributes, i.e. an attribute name no write method produces. It guards the dict-like access to the write result's attribute descriptors.","triggerScenarios":"result['destination_load_jobids'] (typo) or result['some_custom_key'] on a WriteResult object.","commonSituations":"Misspelled attribute names (e.g. 'job_id' instead of 'destination_job_ids'); assuming arbitrary keys exist on the result.","solutions":["Use one of the documented attributes: destination, job_id, method, failed_rows, failed_rows_with_errors, destination_load_jobid_pairs, destination_copy_jobid_pairs, destination_file_prefix.","Check `key in result.attributes` before indexing.","Use attribute access with a valid property name instead of __getitem__."],"exampleFix":"// before\nprint(result['job_ids'])\n// after\nprint(result['destination_job_ids'])","handlingStrategy":"type-guard","validationCode":"if key not in result.attributes:\n    raise KeyError(f'{key} not available; valid: {list(result.attributes)}')","typeGuard":"def has_key(result, key):\n    return key in result.attributes","tryCatchPattern":"try:\n    value = result[key]\nexcept AttributeError:\n    value = None","preventionTips":["Use attribute (dot) access on documented properties instead of string indexing.","Copy attribute names from the docs to avoid typos."],"tags":["apache-beam","bigquery","attribute-error","typo"],"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"}