Skip to content

fix: URL-encode full_name in Unity Catalog API path parameters#1393

Open
nanookclaw wants to merge 1 commit intodatabricks:mainfrom
nanookclaw:fix/url-encode-full-name
Open

fix: URL-encode full_name in Unity Catalog API path parameters#1393
nanookclaw wants to merge 1 commit intodatabricks:mainfrom
nanookclaw:fix/url-encode-full-name

Conversation

@nanookclaw
Copy link
Copy Markdown

Problem

Unity Catalog allows table/schema/model names with special characters (e.g. %, #, ?). When calling methods like tables.get(full_name=db.schema.my_table_#$%), the SDK interpolates full_name directly into the URL path without encoding, causing NotFound errors.

Repro:

from databricks.sdk import WorkspaceClient
ws = WorkspaceClient()
ws.tables.get(db.schema.my_table_#$%)  # NotFound: Table 'db.schema.my_table_' does not exist

Solution

Applied the existing _escape_multi_segment_path_parameter() helper (already used in files.py) to all full_name path parameters in catalog.py. This covers:

  • TablesAPI — get, delete, exists, update
  • SchemasAPI — get, delete, update
  • RegisteredModelsAPI — get, delete, update, get_by_alias, etc.
  • ModelVersionsAPI — get, delete, update
  • TableConstraintsAPI — delete
  • GrantsAPI — get, get_effective, update (with securable_type/full_name)
  • ResourceQuotasAPI — get

The encoding uses urllib.parse.quote() which safely handles special characters while preserving dots and underscores in normal names like catalog.schema.table.

Fixes #1266

Testing

  • Syntax check passes (python3 -m py_compile)
  • Import verification passes
  • Commit is GPG-signed and DCO sign-off

CC @ghansen (issue reporter)

Unity Catalog allows table/schema/model names with special characters
(e.g. '%', '#', '?') which must be URL-encoded when used in REST API
path segments. Previously, methods like tables.get(), schemas.get(),
models.get(), etc. interpolated full_name directly into f-string URLs
without encoding, causing NotFound errors for names containing unsafe
characters.

This change applies the existing _escape_multi_segment_path_parameter()
helper (already used in files.py) to all full_name path parameters in
catalog.py, consistent with how the code generator handles path params
in other service modules.

Fixes databricks#1266

Signed-off-by: Nanook Claw <[email protected]>
Signed-off-by: Nanook <[email protected]>
@github-actions
Copy link
Copy Markdown

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/sdk-py

Inputs:

  • PR number: 1393
  • Commit SHA: fc566c5b7419b89105c9022e8fd3af76cc1a1ac7

Checks will be approved automatically on success.

@github-actions
Copy link
Copy Markdown

Please ensure that the NEXT_CHANGELOG.md file is updated with any relevant changes.
If this is not necessary for your PR, please include the following in your PR description:
NO_CHANGELOG=true
and rerun the job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ISSUE] tables.get does not URL-encode table names with special characters

1 participant