Skip to content

Commit fa6ccec

Browse files
evanbijoy251claude
andcommitted
Platform: fix all-policies path (tenant via header not URL)
The /all-policies endpoint does not take a tenant_id URL segment — the target tenant is resolved from the x-uipath-internal-tenantid header that _build_org_scoped_request already injects. Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
1 parent afc9727 commit fa6ccec

2 files changed

Lines changed: 15 additions & 13 deletions

File tree

packages/uipath-platform/src/uipath/platform/governance/_governance_service.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
- ``POST /{org}/agenticgovernance_/api/v1/runtime/govern`` — compensating
88
governance call fired when a ``guardrail_fallback`` rule matches
99
(see :meth:`GovernanceService.compensate`).
10-
- ``GET /{org}/agenticgovernance_/api/v1/all-policies/{tenant_id}`` — fetch
10+
- ``GET /{org}/agenticgovernance_/api/v1/all-policies`` — fetch
1111
WASM bundle metadata for all hooks (see :meth:`GovernanceService.retrieve_all_policies`).
1212
1313
A third backend endpoint —
@@ -154,10 +154,12 @@ async def get_policy_async(self, context: PolicyContext) -> PolicyResponse:
154154
def retrieve_all_policies(self) -> AllPoliciesResponse:
155155
"""Fetch WASM bundle metadata for all hooks for the active tenant.
156156
157-
Calls ``GET /{org}/agenticgovernance_/api/v1/all-policies/{tenant_id}``
158-
and returns the list of :class:`HookBundle` objects — one per
159-
lifecycle hook that has a compiled WASM policy bundle. Download
160-
each bundle's bytes separately with :meth:`download_bundle`.
157+
Calls ``GET /{org}/agenticgovernance_/api/v1/all-policies`` and
158+
returns the list of :class:`HookBundle` objects — one per
159+
lifecycle hook that has a compiled WASM policy bundle. The target
160+
tenant is resolved from the ``x-uipath-internal-tenantid`` header
161+
injected by :meth:`_build_org_scoped_request`. Download each
162+
bundle's bytes separately with :meth:`download_bundle`.
161163
162164
Returns:
163165
AllPoliciesResponse: List of hook bundles with pre-signed
@@ -181,7 +183,7 @@ def retrieve_all_policies(self) -> AllPoliciesResponse:
181183
```
182184
"""
183185
url, headers = self._build_org_scoped_request(
184-
f"{ALL_POLICIES_API_PATH}/{UiPathConfig.tenant_id}"
186+
ALL_POLICIES_API_PATH
185187
)
186188
response = self.request("GET", url=url, headers=headers)
187189
return AllPoliciesResponse.model_validate(response.json())
@@ -193,7 +195,7 @@ async def retrieve_all_policies_async(self) -> AllPoliciesResponse:
193195
See :meth:`retrieve_all_policies` for parameter and return semantics.
194196
"""
195197
url, headers = self._build_org_scoped_request(
196-
f"{ALL_POLICIES_API_PATH}/{UiPathConfig.tenant_id}"
198+
ALL_POLICIES_API_PATH
197199
)
198200
response = await self.request_async("GET", url=url, headers=headers)
199201
return AllPoliciesResponse.model_validate(response.json())

packages/uipath-platform/tests/services/test_governance_service.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,7 @@ def test_returns_parsed_response(
964964
httpx_mock.add_response(
965965
url=(
966966
f"{base_url}/{ORG_ID}/agenticgovernance_"
967-
f"/api/v1/all-policies/{TENANT_ID}"
967+
f"/api/v1/all-policies"
968968
),
969969
status_code=200,
970970
json=_ALL_POLICIES_RESPONSE,
@@ -992,7 +992,7 @@ def test_returns_empty_list_when_no_bundles(
992992
httpx_mock.add_response(
993993
url=(
994994
f"{base_url}/{ORG_ID}/agenticgovernance_"
995-
f"/api/v1/all-policies/{TENANT_ID}"
995+
f"/api/v1/all-policies"
996996
),
997997
status_code=200,
998998
json={"hookBundles": []},
@@ -1019,7 +1019,7 @@ def capture(request: httpx.Request) -> httpx.Response:
10191019
capture,
10201020
url=(
10211021
f"{base_url}/{ORG_ID}/agenticgovernance_"
1022-
f"/api/v1/all-policies/{TENANT_ID}"
1022+
f"/api/v1/all-policies"
10231023
),
10241024
)
10251025

@@ -1067,7 +1067,7 @@ def test_raises_on_http_error(
10671067
httpx_mock.add_response(
10681068
url=(
10691069
f"{base_url}/{ORG_ID}/agenticgovernance_"
1070-
f"/api/v1/all-policies/{TENANT_ID}"
1070+
f"/api/v1/all-policies"
10711071
),
10721072
status_code=500,
10731073
text="server error",
@@ -1093,7 +1093,7 @@ def capture(request: httpx.Request) -> httpx.Response:
10931093

10941094
httpx_mock.add_callback(
10951095
capture,
1096-
url=f"http://localhost:8123/api/v1/all-policies/{TENANT_ID}",
1096+
url=f"http://localhost:8123/api/v1/all-policies",
10971097
)
10981098

10991099
service.retrieve_all_policies()
@@ -1111,7 +1111,7 @@ async def test_async_returns_parsed_response(
11111111
httpx_mock.add_response(
11121112
url=(
11131113
f"{base_url}/{ORG_ID}/agenticgovernance_"
1114-
f"/api/v1/all-policies/{TENANT_ID}"
1114+
f"/api/v1/all-policies"
11151115
),
11161116
status_code=200,
11171117
json=_ALL_POLICIES_RESPONSE,

0 commit comments

Comments
 (0)