{"record":{"id":"3dd8f9612bbb64c3","repo":"apache/beam","slug":"readfrombigquery-requires-a-gcs-location-to-be-provided","errorCode":null,"errorMessage":"ReadFromBigQuery requires a GCS location to be provided. Neither gcs_location in the constructor nor the fallback option --temp_location is set.","messagePattern":"ReadFromBigQuery requires a GCS location to be provided\\. Neither gcs_location in the constructor nor the fallback option --temp_location is set\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/io/gcp/bigquery_read_internal.py","lineNumber":88,"sourceCode":"  \"\"\"Returns the fully qualified Google Cloud Storage URI where the\n  extracted table should be written.\n  \"\"\"\n  file_pattern = 'bigquery-table-dump-*.json'\n\n  gcs_location = None\n  if gcs_location_vp is not None:\n    if isinstance(gcs_location_vp, ValueProvider):\n      gcs_location = gcs_location_vp.get()\n    else:\n      gcs_location = gcs_location_vp\n\n  if gcs_location is not None:\n    gcs_base = gcs_location\n  elif temp_location is not None:\n    gcs_base = temp_location\n    _LOGGER.debug(\"gcs_location is empty, using temp_location instead\")\n  else:\n    raise ValueError(\n        'ReadFromBigQuery requires a GCS location to be provided. Neither '\n        'gcs_location in the constructor nor the fallback option '\n        '--temp_location is set.')\n\n  if not unique_id:\n    unique_id = uuid.uuid4().hex\n\n  if directory_only:\n    return FileSystems.join(gcs_base, unique_id)\n  else:\n    return FileSystems.join(gcs_base, unique_id, file_pattern)\n\n\nclass _PassThroughThenCleanup(PTransform):\n  \"\"\"A PTransform that invokes a DoFn after the input PCollection has been\n    processed.\n\n    DoFn should have arguments (element, side_input, cleanup_signal).","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/io/gcp/bigquery_read_internal.py#L70-L106","documentation":"ReadFromBigQuery (batch extract via FILE_LOADS/Avro export) exports query results to files in GCS before reading them back. bigquery_export_destination_uri builds that export URI from gcs_location, falling back to --temp_location; if neither is set it raises this ValueError because there is nowhere to write the export files.","triggerScenarios":"Using ReadFromBigQuery (method=EXPORT) with gcs_location=None and no --temp_location in PipelineOptions; also hit by _export_files and file_path_to_remove when resolving the URI at runtime with an empty runtime ValueProvider.","commonSituations":"Running locally without --temp_location; setting gcs_location as a RuntimeValueProvider but never supplying the runtime value; forgetting GCS requirements when migrating from STREAMING_INSERTS reads.","solutions":["Pass gcs_location='gs://my-bucket/temp' to ReadFromBigQuery.","Add --temp_location gs://my-bucket/temp to your PipelineOptions.","If gcs_location is a runtime ValueProvider, ensure the value is actually supplied at job submission."],"exampleFix":"// before\nbeam.io.ReadFromBigQuery(query='SELECT * FROM t', project='p')\n// after\nbeam.io.ReadFromBigQuery(query='SELECT * FROM t', project='p', gcs_location='gs://my-bucket/temp')","handlingStrategy":"validation","validationCode":"opts = pipeline.options.view_as(beam.options.pipeline_options.GoogleCloudOptions)\nif gcs_location is None and not opts.temp_location:\n    raise ValueError('ReadFromBigQuery needs gcs_location or --temp_location')","typeGuard":"def has_gcs_read_location(gcs_location, temp_location) -> bool:\n    loc = gcs_location or temp_location\n    return isinstance(loc, str) and loc.startswith('gs://')","tryCatchPattern":null,"preventionTips":["Always set gcs_location for export-based reads","Supply runtime ValueProvider values at job submission","Keep --temp_location set in all production pipeline options"],"tags":["gcp","bigquery","gcs","configuration"],"backgroundTag":"missing-required-config-field","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}