Skip to content

Commit a8664be

Browse files
refactor(staging): share local path validation message
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
1 parent 3efbcc9 commit a8664be

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

‎src/databricks/sql/backend/kernel/client.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@
7373
# http_path). Forwarding either is redundant and trips the kernel's
7474
# per-request skip-and-warn.
7575
_KERNEL_MANAGED_HEADERS = frozenset({"authorization", "x-databricks-org-id"})
76+
_STAGING_PATHS_TYPE_ERROR = (
77+
"staging_allowed_local_path must be a string or a list of "
78+
"strings or os.PathLike objects"
79+
)
7680

7781

7882
def _strip_leading_sql_comments(sql: str) -> str:
@@ -581,9 +585,7 @@ def execute_command(
581585
if allowed_paths is not None and not isinstance(
582586
allowed_paths, (str, list)
583587
):
584-
raise ProgrammingError(
585-
"staging_allowed_local_path must be a string or a list of strings or os.PathLike objects"
586-
)
588+
raise ProgrammingError(_STAGING_PATHS_TYPE_ERROR)
587589
if isinstance(allowed_paths, str):
588590
allowed_paths = [allowed_paths]
589591
try:
@@ -593,9 +595,7 @@ def execute_command(
593595
if any(not isinstance(path, str) for path in normalized_paths):
594596
raise TypeError("Local paths must resolve to strings")
595597
except (TypeError, ValueError) as exc:
596-
raise ProgrammingError(
597-
"staging_allowed_local_path must be a string or a list of strings or os.PathLike objects"
598-
) from exc
598+
raise ProgrammingError(_STAGING_PATHS_TYPE_ERROR) from exc
599599
set_paths(normalized_paths)
600600
elif staging_verb is not None:
601601
raise NotSupportedError(

0 commit comments

Comments
 (0)