{"record":{"id":"8089ff5a76117129","repo":"apache/beam","slug":"cannot-get-attribute-because-it-is-not-produced-by-the-self","errorCode":null,"errorMessage":"Cannot get {attribute} because it is not produced by the {self._method} write method. Note: only {valid_methods} produces this attribute.","messagePattern":"Cannot get (.+?) because it is not produced by the (.+?) write method\\. Note: only (.+?) produces this attribute\\.","errorType":"exception","errorClass":"AttributeError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/io/gcp/bigquery.py","lineNumber":2612,"sourceCode":"    self._failed_rows = failed_rows\n    self._failed_rows_with_errors = failed_rows_with_errors\n\n    from apache_beam.io.gcp.bigquery_file_loads import BigQueryBatchFileLoads\n    self.attributes = {\n        BigQueryWriteFn.FAILED_ROWS: WriteResult.failed_rows,\n        BigQueryWriteFn.FAILED_ROWS_WITH_ERRORS: WriteResult.\n        failed_rows_with_errors,\n        BigQueryBatchFileLoads.DESTINATION_JOBID_PAIRS: WriteResult.\n        destination_load_jobid_pairs,\n        BigQueryBatchFileLoads.DESTINATION_FILE_PAIRS: WriteResult.\n        destination_file_pairs,\n        BigQueryBatchFileLoads.DESTINATION_COPY_JOBID_PAIRS: WriteResult.\n        destination_copy_jobid_pairs,\n    }\n\n  def validate(self, valid_methods, attribute):\n    if self._method not in valid_methods:\n      raise AttributeError(\n          f'Cannot get {attribute} because it is not produced '\n          f'by the {self._method} write method. Note: only '\n          f'{valid_methods} produces this attribute.')\n\n  @property\n  def destination_load_jobid_pairs(\n      self) -> PCollection[tuple[str, JobReference]]:\n    \"\"\"A ``FILE_LOADS`` method attribute\n\n    Returns: A PCollection of the table destinations that were successfully\n      loaded to using the batch load API, along with the load job IDs.\n\n    Raises: AttributeError: if accessed with a write method\n    besides ``FILE_LOADS``.\"\"\"\n    self.validate([WriteToBigQuery.Method.FILE_LOADS],\n                  'DESTINATION_JOBID_PAIRS')\n\n    return self._destination_load_jobid_pairs","sourceCodeStart":2594,"sourceCodeEnd":2630,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/io/gcp/bigquery.py#L2594-L2630","documentation":"WriteResult.validate() raises AttributeError when reading a result attribute (e.g. destination_job_ids) that is only produced by certain write methods, but the WriteResult came from a different method (e.g. STREAMING_INSERTS). Each write method produces a distinct subset of result attributes.","triggerScenarios":"Calling result.destination_load_jobid_pairs, destination_file_prefix, or destination_copy_jobid_pairs on a WriteResult whose method is STREAMING_INSERTS or STORAGE_WRITE_API.","commonSituations":"Generic pipeline code that inspects write results regardless of which write method was configured; switching write methods without updating post-write reporting code.","solutions":["Check result.method before accessing method-specific attributes.","Only access load-job attributes (destination_load_jobid_pairs, destination_copy_jobid_pairs, destination_file_prefix) when using BigQueryBatchFileLoads/FILE_LOADS.","Restructure code to use attribute sets valid for the method actually used."],"exampleFix":"// before\nresult = t | WriteToBigQuery(..., method='STREAMING_INSERTS')\nprint(result.destination_load_jobid_pairs)\n// after\nif result.method == WriteToBigQuery.Method.FILE_LOADS:\n  print(result.destination_load_jobid_pairs)","handlingStrategy":"try-catch","validationCode":"if result.method in (WriteToBigQuery.Method.FILE_LOADS,):\n    job_ids = result.destination_load_jobid_pairs","typeGuard":"def has_load_attrs(result):\n    return result.method in (WriteToBigQuery.Method.FILE_LOADS,)","tryCatchPattern":"try:\n    pairs = result.destination_load_jobid_pairs\nexcept AttributeError:\n    pairs = None  # method doesn't produce load job ids","preventionTips":["Check WriteResult.method before reading method-specific attributes.","Read the WriteResult attribute table in the docs to know which method produces which attribute."],"tags":["apache-beam","bigquery","attribute-error","api-misuse"],"backgroundTag":"unsupported-operation","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"}