Skip to content

Commit 0ac9070

Browse files
authored
fix(platform): buckets.delete honors folder_path/folder_key args (#1729)
1 parent 1e40891 commit 0ac9070

5 files changed

Lines changed: 89 additions & 5 deletions

File tree

packages/uipath-platform/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "uipath-platform"
3-
version = "0.1.68"
3+
version = "0.1.69"
44
description = "HTTP client library for programmatic access to UiPath Platform"
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"

packages/uipath-platform/src/uipath/platform/orchestrator/_buckets_service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ def delete(
365365
self.request(
366366
"DELETE",
367367
url=f"/orchestrator_/odata/Buckets({bucket.id})",
368-
headers={**self.folder_headers},
368+
headers={**header_folder(folder_key, folder_path)},
369369
)
370370

371371
@resource_override(resource_type="bucket")
@@ -386,7 +386,7 @@ async def delete_async(
386386
await self.request_async(
387387
"DELETE",
388388
url=f"/orchestrator_/odata/Buckets({bucket.id})",
389-
headers={**self.folder_headers},
389+
headers={**header_folder(folder_key, folder_path)},
390390
)
391391

392392
@resource_override(resource_type="bucket")

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

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,90 @@ async def test_create_async(
646646
assert bucket.id == 1
647647

648648

649+
class TestDelete:
650+
"""Tests for delete() / delete_async().
651+
652+
Regression coverage for UV-14977: delete() must build the folder header
653+
from the folder_path/folder_key arguments (via header_folder), not solely
654+
from the UIPATH_FOLDER_PATH / UIPATH_FOLDER_KEY env vars.
655+
"""
656+
657+
def test_delete_by_name_uses_folder_path_arg(
658+
self,
659+
httpx_mock: HTTPXMock,
660+
service: BucketsService,
661+
base_url: str,
662+
org: str,
663+
tenant: str,
664+
):
665+
"""delete(name=..., folder_path=...) sends the arg folder header on DELETE."""
666+
# retrieve() locates the bucket in the target folder
667+
httpx_mock.add_response(
668+
url=f"{base_url}{org}{tenant}/orchestrator_/odata/Buckets?$filter=Name eq 'old-storage'&$top=1",
669+
status_code=200,
670+
json={"value": [{"Id": 203380, "Name": "old-storage", "Identifier": "id"}]},
671+
match_headers={"x-uipath-folderpath": "Playground"},
672+
)
673+
# the DELETE must carry the arg folder header (not the env-var fallback)
674+
httpx_mock.add_response(
675+
url=f"{base_url}{org}{tenant}/orchestrator_/odata/Buckets(203380)",
676+
method="DELETE",
677+
status_code=204,
678+
match_headers={"x-uipath-folderpath": "Playground"},
679+
)
680+
681+
service.delete(name="old-storage", folder_path="Playground")
682+
683+
def test_delete_by_key_uses_folder_key_arg(
684+
self,
685+
httpx_mock: HTTPXMock,
686+
service: BucketsService,
687+
base_url: str,
688+
org: str,
689+
tenant: str,
690+
):
691+
"""delete(key=..., folder_key=...) sends the arg folder-key header on DELETE."""
692+
httpx_mock.add_response(
693+
url=f"{base_url}{org}{tenant}/orchestrator_/odata/Buckets/UiPath.Server.Configuration.OData.GetByKey(identifier='bucket-key')",
694+
status_code=200,
695+
json={"value": [{"Id": 55, "Name": "kbucket", "Identifier": "bucket-key"}]},
696+
match_headers={"x-uipath-folderkey": "folder-123"},
697+
)
698+
httpx_mock.add_response(
699+
url=f"{base_url}{org}{tenant}/orchestrator_/odata/Buckets(55)",
700+
method="DELETE",
701+
status_code=204,
702+
match_headers={"x-uipath-folderkey": "folder-123"},
703+
)
704+
705+
service.delete(key="bucket-key", folder_key="folder-123")
706+
707+
@pytest.mark.asyncio
708+
async def test_delete_async_uses_folder_path_arg(
709+
self,
710+
httpx_mock: HTTPXMock,
711+
service: BucketsService,
712+
base_url: str,
713+
org: str,
714+
tenant: str,
715+
):
716+
"""Async version honors the folder_path argument on DELETE."""
717+
httpx_mock.add_response(
718+
url=f"{base_url}{org}{tenant}/orchestrator_/odata/Buckets?$filter=Name eq 'old-storage'&$top=1",
719+
status_code=200,
720+
json={"value": [{"Id": 99, "Name": "old-storage", "Identifier": "id"}]},
721+
match_headers={"x-uipath-folderpath": "Playground"},
722+
)
723+
httpx_mock.add_response(
724+
url=f"{base_url}{org}{tenant}/orchestrator_/odata/Buckets(99)",
725+
method="DELETE",
726+
status_code=204,
727+
match_headers={"x-uipath-folderpath": "Playground"},
728+
)
729+
730+
await service.delete_async(name="old-storage", folder_path="Playground")
731+
732+
649733
class TestEdgeCases:
650734
"""Tests for edge cases and error handling."""
651735

packages/uipath-platform/uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/uipath/uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)