{"record":{"id":"b2e30ee023aea2ae","repo":"apache/beam","slug":"only-one-of-source-uris-and-source-stream-may-be-specified","errorCode":null,"errorMessage":"Only one of source_uris and source_stream may be specified. Got both.","messagePattern":"Only one of source_uris and source_stream may be specified\\. Got both\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/io/gcp/bigquery_tools.py","lineNumber":556,"sourceCode":"      project_id,\n      job_id,\n      table_reference,\n      source_uris=None,\n      source_stream=None,\n      schema=None,\n      write_disposition=None,\n      create_disposition=None,\n      additional_load_parameters=None,\n      source_format=None,\n      job_labels=None):\n\n    if not source_uris and not source_stream:\n      _LOGGER.warning(\n          'Both source URIs and source stream are not provided. BigQuery load '\n          'job will not load any data.')\n\n    if source_uris and source_stream:\n      raise ValueError(\n          'Only one of source_uris and source_stream may be specified. '\n          'Got both.')\n\n    if source_uris is None:\n      source_uris = []\n\n    additional_load_parameters = additional_load_parameters or {}\n    job_schema = None if schema == 'SCHEMA_AUTODETECT' else schema\n    reference = bigquery.JobReference(jobId=job_id, projectId=project_id)\n    request = bigquery.BigqueryJobsInsertRequest(\n        projectId=project_id,\n        job=bigquery.Job(\n            configuration=bigquery.JobConfiguration(\n                load=bigquery.JobConfigurationLoad(\n                    sourceUris=source_uris,\n                    destinationTable=table_reference,\n                    schema=job_schema,\n                    writeDisposition=write_disposition,","sourceCodeStart":538,"sourceCodeEnd":574,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/io/gcp/bigquery_tools.py#L538-L574","documentation":"Raised by BigQueryWrapper._insert_load_job when both source_uris (GCS files) and source_stream (in-memory bytes) are provided. A BigQuery load job can ingest from a URI list or a stream, not both, so Beam rejects the conflicting input.","triggerScenarios":"Calling _insert_load_job(..., source_uris=['gs://...'], source_stream=<bytes>) directly, or perform_load_job with both a file list and a stream configured by different code paths.","commonSituations":"Switching a pipeline from GCS-based loading to streaming loads and leaving the old URIs configured; fallback logic that sets both 'just in case'; template options where source URI list is non-empty by default.","solutions":["Set source_stream to None and load from GCS via source_uris.","Or set source_uris to None/empty and load the in-memory stream.","Add a check in your pipeline config so exactly one source is populated.","If both inputs exist, first write the stream to GCS and then pass only source_uris."],"exampleFix":"// before\nwrapper._insert_load_job(job_ref, 'CSV', source_uris=uris, source_stream=data)\n\n// after\nwrapper._insert_load_job(job_ref, 'CSV', source_uris=uris, source_stream=None)","handlingStrategy":"validation","validationCode":"if source_uris and source_stream:\n    raise ValueError('choose one load source: GCS URIs or in-memory stream')","typeGuard":"def has_single_load_source(uris, stream):\n    return bool(uris) != bool(stream)","tryCatchPattern":"try:\n    wrapper.perform_load_job(..., source_uris=uris, source_stream=data)\nexcept ValueError as e:\n    if 'Only one of source_uris and source_stream' in str(e):\n        choose_and_set_single_source()  # explicitly clear the other\n    else:\n        raise","preventionTips":["Centralize load-job creation in one helper that enforces a single source","When switching between GCS and stream loading, explicitly None out the unused argument","Unit-test the source-selection config path"],"tags":["bigquery","load-job","conflicting-options","python"],"backgroundTag":"mutually-exclusive-options","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"}