{"record":{"id":"ce1c30d0cdc02a5c","repo":"apache/beam","slug":"custom-gcs-temp-location-must-be-str-or-valueprovider","errorCode":null,"errorMessage":"custom_gcs_temp_location must be str or ValueProvider","messagePattern":"custom_gcs_temp_location must be str or ValueProvider","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/io/gcp/bigquery_file_loads.py","lineNumber":997,"sourceCode":"    self.project = project\n    self.create_disposition = create_disposition\n    self.write_disposition = write_disposition\n    self.triggering_frequency = triggering_frequency\n    self.with_auto_sharding = with_auto_sharding\n    self.max_file_size = max_file_size or _DEFAULT_MAX_FILE_SIZE\n    self.max_files_per_bundle = (\n        max_files_per_bundle or _DEFAULT_MAX_WRITERS_PER_BUNDLE)\n    self.max_partition_size = max_partition_size or _MAXIMUM_LOAD_SIZE\n    self.max_files_per_partition = (\n        max_files_per_partition or _MAXIMUM_SOURCE_URIS)\n    if (isinstance(custom_gcs_temp_location, str) or\n        custom_gcs_temp_location is None):\n      self._custom_gcs_temp_location = vp.StaticValueProvider(\n          str, custom_gcs_temp_location or '')\n    elif isinstance(custom_gcs_temp_location, vp.ValueProvider):\n      self._custom_gcs_temp_location = custom_gcs_temp_location\n    else:\n      raise ValueError('custom_gcs_temp_location must be str or ValueProvider')\n\n    self.test_client = test_client\n    self.schema = schema\n    self._temp_file_format = temp_file_format or bigquery_tools.FileFormat.JSON\n\n    # If we have multiple destinations, then we will have multiple load jobs,\n    # thus we will need temporary tables for atomicity.\n    self.dynamic_destinations = bool(callable(destination))\n\n    self.additional_bq_parameters = additional_bq_parameters or {}\n    self.table_side_inputs = table_side_inputs or ()\n    self.schema_side_inputs = schema_side_inputs or ()\n\n    self.is_streaming_pipeline = is_streaming_pipeline\n    self.load_job_project_id = load_job_project_id\n    self._validate = validate\n    if self._validate:\n      self.verify()","sourceCodeStart":979,"sourceCodeEnd":1015,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/io/gcp/bigquery_file_loads.py#L979-L1015","documentation":"BigQueryBatchFileLoads stores the custom GCS staging location internally as a ValueProvider so it can be resolved at runtime. The __init__ accepts either a plain string or a ValueProvider; anything else (int, None with a non-empty-able mismatch, dict, etc.) falls through to this ValueError.","triggerScenarios":"Calling WriteToBigQuery/BigQueryBatchFileLoads with custom_gcs_temp_location set to a non-str, non-ValueProvider object (e.g. bytes, int, Path object).","commonSituations":"Passing a pathlib.Path or os.PathLike bucket path instead of str, or wrapping the location incorrectly when plumbing runtime parameters.","solutions":["Convert the value: custom_gcs_temp_location=str(my_path).","Wrap runtime values: custom_gcs_temp_location=RuntimeValueProvider(str, ...) or StaticValueProvider(str, value).","Omit the parameter to fall back to --temp_location."],"exampleFix":"// before\nbeam.io.WriteToBigQuery(table, custom_gcs_temp_location=pathlib.Path('gs://bucket/temp'))\n// after\nbeam.io.WriteToBigQuery(table, custom_gcs_temp_location=str(pathlib.Path('gs://bucket/temp')))","handlingStrategy":"type-guard","validationCode":"if custom_gcs_temp_location is not None and not isinstance(custom_gcs_temp_location, (str, vp.ValueProvider)):\n    raise TypeError('custom_gcs_temp_location must be str or ValueProvider')","typeGuard":"def is_valid_temp_location(v) -> bool:\n    return v is None or isinstance(v, (str, vp.ValueProvider))","tryCatchPattern":null,"preventionTips":["Coerce pathlib/PathLike values with str() before passing","Wrap runtime values in ValueProviders","Check constructor signatures for accepted types"],"tags":["bigquery","type-mismatch","beam","python"],"backgroundTag":"type-mismatch","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"}