Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions sdks/python/apache_beam/options/pipeline_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -1249,12 +1249,22 @@ def _warn_if_soft_delete_policy_enabled(self, arg_name):
def _handle_temp_and_staging_locations(self, validator):
temp_errors = validator.validate_gcs_path(self, 'temp_location')
staging_errors = validator.validate_gcs_path(self, 'staging_location')

temp_location = getattr(self, 'temp_location', None)
staging_location = getattr(self, 'staging_location', None)

if temp_location is not None and temp_errors:
_LOGGER.warning(temp_errors[0])

if staging_location is not None and staging_errors:
_LOGGER.warning(staging_errors[0])

if temp_errors and not staging_errors:
setattr(self, 'temp_location', getattr(self, 'staging_location'))
setattr(self, 'temp_location', staging_location)
self._warn_if_soft_delete_policy_enabled('staging_location')
return []
elif staging_errors and not temp_errors:
setattr(self, 'staging_location', getattr(self, 'temp_location'))
setattr(self, 'staging_location', temp_location)
self._warn_if_soft_delete_policy_enabled('temp_location')
return []
Comment thread
tvalentyn marked this conversation as resolved.
elif not staging_errors and not temp_errors:
Expand Down
10 changes: 9 additions & 1 deletion sdks/python/apache_beam/options/pipeline_options_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,15 @@ def validate_gcs_path(self, view, arg_name):

if not self.is_full_string_match(self.GCS_BUCKET, bucket):
return self._validate_error(self.ERR_INVALID_GCS_BUCKET, arg, arg_name)
if gcs_object is None or '\n' in gcs_object or '\r' in gcs_object:
if gcs_object is None:
return self._validate_error(
"Invalid GCS path: '%s' given for option: %s. "
"Did you mean: 'gs://%s/ or gs://some_bucket/%s'?",
arg,
arg_name,
bucket,
bucket)
if '\n' in gcs_object or '\r' in gcs_object:
return self._validate_error(self.ERR_INVALID_GCS_OBJECT, arg, arg_name)
return []

Expand Down
Loading