Skip to content

Allow providing base path for UC API Client - #1130

Merged
tdas merged 7 commits into
unitycatalog:mainfrom
urosstan-db:allow-providing-base-path-for-ac-api-client
Nov 16, 2025
Merged

tdas merged 7 commits into
unitycatalog:mainfrom
urosstan-db:allow-providing-base-path-for-ac-api-client

Conversation

@urosstan-db

@urosstan-db urosstan-db commented Oct 24, 2025 •

Copy link
Copy Markdown
Contributor

PR Checklist

  • Certain vendors may register UC API under a certain path (e.g. Microsoft Fabric API registers it under https://onelake.table.fabric.microsoft.com/delta/<Workspace name or workspace ID>/<Item name or item ID>/api/2.1/unity-catalog/)
  • New test suite added
  • This is a behavioural change, since if someone provided a URL earlier with a specific path, then the path would be just ignored (e.g., the fabric API I provided above would be translated to https://onelake.table.fabric.microsoft.com/api/2.1/unity-catalog/). But probably no users provide a URL with a path, since the UC API could not be hit prior to this fix.
  • Base URL prior this change was api/2.1/unity-catalog/, while now it is basePathFromProvidedUrl + api/2.1/unity-catalog/

Description of changes

  • In the API Client factory, set the base path of the provided URL where the UC API is registered. This code path is hit when we initialize UCSingleCatalog.
  • Behaviour prior this change caused failure on URIs with certain path:
image

@urosstan-db urosstan-db changed the title Allow providing base path for UC API Client. Allow providing base path for UC API Client Oct 24, 2025
@urosstan-db
urosstan-db force-pushed the allow-providing-base-path-for-ac-api-client branch from 49358c3 to abdc6c1 Compare October 24, 2025 13:50
.setPort(url.getPort())
.setScheme(url.getScheme());
.setScheme(url.getScheme())
.setBasePath(basePath);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This base path was set in ApiClient constructor to /api/2.1/unity-catalog, because ApiClient::getDefaultBaseUri is http://localhost:8080/api/2.1/unity-catalog, while we invoke updateBaseUri(getDefaultBaseUri()); in constructor, so base path was already set to /api/2.1/unity-catalog.

@openinx openinx Oct 28, 2025 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't set the /api/2.1/unity-catalog, what's the version (or base path) that the API call will go through by default ?

Copy link
Copy Markdown
Contributor Author

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I think I got the point. Thanks for the information. Could you please help to add some unit tests to address this ? Seems like it's hard to get this context correctly. Thanks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I added ApiClientFactoryTest and one method to test base URI for all APIs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you leave this context as a comment in the code on why basePath needs to be set? this is important context that should be captured in the code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tdas Yes, that's great point

@openinx

openinx commented Oct 28, 2025

Copy link
Copy Markdown
Collaborator

Hi @urosstan-db , thanks for the contributionn. Could you please help to check the DCO issue ?

private ApiClientFactory() {}

public static ApiClient createApiClient(URI url, String token) {
String basePath = url.getPath() + BASE_PATH;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to concat the url.getPath() and BASE_PATH to set the basePath for the ApiClient ?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

( since we've already set the host and port for the apiClient ).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getPath returns the part of URI after host and port.
https://docs.oracle.com/javase/8/docs/api/java/net/URI.html
https://www.geeksforgeeks.org/java/uri-getpath-method-in-java-with-examples/

Since we set host and port only currently (prior to this PR), the path is just omitted in the final URL of ApiClient, which prevents us from connecting to the UC API registered at some endpoint with a path.

@urosstan-db
urosstan-db force-pushed the allow-providing-base-path-for-ac-api-client branch from f40d81f to aac2e39 Compare October 29, 2025 16:58

@rameshchandra rameshchandra left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@urosstan-db please test before merging

Signed-off-by: Uros Stankovic <[email protected]>
@urosstan-db
urosstan-db force-pushed the allow-providing-base-path-for-ac-api-client branch from 79a22fb to fe9cad4 Compare October 30, 2025 19:32

@openinx openinx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @urosstan-db for the contribution !

public void testApiClientBaseUri() {
String token = "";

URI uriDatabricks = URI.create("https://adb-1234567890123456.3.azuredatabricks.net");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which of these 2 cases passed before your changes to the factory?
I am trying to make sure that we are capturing in a test that the existing URLs are not broken.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This URI passed, uriDatabricks, since it has no path in URL, while fabric failed

Signed-off-by: Uros Stankovic <[email protected]>
Signed-off-by: Uros Stankovic <[email protected]>
Signed-off-by: Uros Stankovic <[email protected]>
@tdas
tdas merged commit 37f5755 into unitycatalog:main Nov 16, 2025
tdas pushed a commit that referenced this pull request Nov 16, 2025
**PR Checklist**
- Certain vendors may register UC API under a certain path (e.g.
Microsoft Fabric API registers it under
`https://onelake.table.fabric.microsoft.com/delta/<Workspace name or
workspace ID>/<Item name or item ID>/api/2.1/unity-catalog/`)
- New test suite added
- This is a behavioural change, since if someone provided a URL earlier
with a specific path, then the path would be just ignored (e.g., the
fabric API I provided above would be translated to
`https://onelake.table.fabric.microsoft.com/api/2.1/unity-catalog/`).
But probably no users provide a URL with a path, since the UC API could
not be hit prior to this fix.
- Base URL prior this change was `api/2.1/unity-catalog/`, while now it
is `basePathFromProvidedUrl` + `api/2.1/unity-catalog/`

**Description of changes**
- In the API Client factory, set the base path of the provided URL where
the UC API is registered. This code path is hit when we initialize
`UCSingleCatalog`.
- Behaviour prior this change caused failure on URIs with certain path:
<img width="1852" height="194" alt="image"
src="https://github.com/user-attachments/assets/ae2d67cb-2d92-4483-bd4a-07ee961200e6"
/>

---------

Signed-off-by: Uros Stankovic <[email protected]>
(cherry picked from commit 37f5755)
@tdas

tdas commented Nov 16, 2025

Copy link
Copy Markdown
Contributor

Successfully created backport PR for branch-0.3:

tdas pushed a commit that referenced this pull request Nov 16, 2025
**PR Checklist**
- Certain vendors may register UC API under a certain path (e.g.
Microsoft Fabric API registers it under
`https://onelake.table.fabric.microsoft.com/delta/<Workspace name or
workspace ID>/<Item name or item ID>/api/2.1/unity-catalog/`)
- New test suite added
- This is a behavioural change, since if someone provided a URL earlier
with a specific path, then the path would be just ignored (e.g., the
fabric API I provided above would be translated to
`https://onelake.table.fabric.microsoft.com/api/2.1/unity-catalog/`).
But probably no users provide a URL with a path, since the UC API could
not be hit prior to this fix.
- Base URL prior this change was `api/2.1/unity-catalog/`, while now it
is `basePathFromProvidedUrl` + `api/2.1/unity-catalog/`

**Description of changes**
- In the API Client factory, set the base path of the provided URL where
the UC API is registered. This code path is hit when we initialize
`UCSingleCatalog`.
- Behaviour prior this change caused failure on URIs with certain path:
<img width="1852" height="194" alt="image"
src="https://github.com/user-attachments/assets/ae2d67cb-2d92-4483-bd4a-07ee961200e6"
/>

---------

Signed-off-by: Uros Stankovic <[email protected]>
(cherry picked from commit 37f5755)
Signed-off-by: Uros Stankovic <[email protected]>
tdas added a commit that referenced this pull request Nov 16, 2025
)

Backport of #1130 to `branch-0.3`.

---

**PR Checklist**
- Certain vendors may register UC API under a certain path (e.g.
Microsoft Fabric API registers it under
`https://onelake.table.fabric.microsoft.com/delta/<Workspace name or
workspace ID>/<Item name or item ID>/api/2.1/unity-catalog/`)
- New test suite added
- This is a behavioural change, since if someone provided a URL earlier
with a specific path, then the path would be just ignored (e.g., the
fabric API I provided above would be translated to
`https://onelake.table.fabric.microsoft.com/api/2.1/unity-catalog/`).
But probably no users provide a URL with a path, since the UC API could
not be hit prior to this fix.
- Base URL prior this change was `api/2.1/unity-catalog/`, while now it
is `basePathFromProvidedUrl` + `api/2.1/unity-catalog/`

**Description of changes**
- In the API Client factory, set the base path of the provided URL where
the UC API is registered. This code path is hit when we initialize
`UCSingleCatalog`.
- Behaviour prior this change caused failure on URIs with certain path:
<img width="1852" height="194" alt="image"
src="https://github.com/user-attachments/assets/ae2d67cb-2d92-4483-bd4a-07ee961200e6"
/>

Signed-off-by: Uros Stankovic <[email protected]>
Signed-off-by: Uros Stankovic <[email protected]>
Co-authored-by: Uros Stankovic <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants