Skip to content

Commit db66869

Browse files
authored
Log temp/staging location options parsing errors. (#39305)
* Log temp/staging location options parsing errors. * yapf
1 parent 73162ce commit db66869

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

sdks/python/apache_beam/options/pipeline_options.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,12 +1249,22 @@ def _warn_if_soft_delete_policy_enabled(self, arg_name):
12491249
def _handle_temp_and_staging_locations(self, validator):
12501250
temp_errors = validator.validate_gcs_path(self, 'temp_location')
12511251
staging_errors = validator.validate_gcs_path(self, 'staging_location')
1252+
1253+
temp_location = getattr(self, 'temp_location', None)
1254+
staging_location = getattr(self, 'staging_location', None)
1255+
1256+
if temp_location is not None and temp_errors:
1257+
_LOGGER.warning(temp_errors[0])
1258+
1259+
if staging_location is not None and staging_errors:
1260+
_LOGGER.warning(staging_errors[0])
1261+
12521262
if temp_errors and not staging_errors:
1253-
setattr(self, 'temp_location', getattr(self, 'staging_location'))
1263+
setattr(self, 'temp_location', staging_location)
12541264
self._warn_if_soft_delete_policy_enabled('staging_location')
12551265
return []
12561266
elif staging_errors and not temp_errors:
1257-
setattr(self, 'staging_location', getattr(self, 'temp_location'))
1267+
setattr(self, 'staging_location', temp_location)
12581268
self._warn_if_soft_delete_policy_enabled('temp_location')
12591269
return []
12601270
elif not staging_errors and not temp_errors:

sdks/python/apache_beam/options/pipeline_options_validator.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,15 @@ def validate_gcs_path(self, view, arg_name):
203203

204204
if not self.is_full_string_match(self.GCS_BUCKET, bucket):
205205
return self._validate_error(self.ERR_INVALID_GCS_BUCKET, arg, arg_name)
206-
if gcs_object is None or '\n' in gcs_object or '\r' in gcs_object:
206+
if gcs_object is None:
207+
return self._validate_error(
208+
"Invalid GCS path: '%s' given for option: %s. "
209+
"Did you mean: 'gs://%s/ or gs://some_bucket/%s'?",
210+
arg,
211+
arg_name,
212+
bucket,
213+
bucket)
214+
if '\n' in gcs_object or '\r' in gcs_object:
207215
return self._validate_error(self.ERR_INVALID_GCS_OBJECT, arg, arg_name)
208216
return []
209217

0 commit comments

Comments
 (0)