Skip to content

Commit 43ec2a1

Browse files
committed
feat: fix logic for getting ID from resource
1 parent 36ebe6e commit 43ec2a1

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/secops/chronicle/utils/format_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def format_resource_id(resource_id: str) -> str:
3636
The extracted ID from the resource string, or the original string if it doesn't match the expected format.
3737
"""
3838
if resource_id.startswith("projects/"):
39-
return resource_id.split("projects/")[-1]
39+
return resource_id.split("/")[-1]
4040
return resource_id
4141

4242

tests/chronicle/utils/test_format_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ def test_format_resource_id_returns_bare_id_unchanged() -> None:
2727

2828

2929
def test_format_resource_id_extracts_id_from_full_resource_name() -> None:
30-
# Full resource name should have everything up to and including "projects/" stripped
30+
# Full resource name should have the ID extracted correctly
3131
full_name = "projects/12345/locations/eu/instances/my-instance/nativeDashboards/123-ID-abc"
32-
assert format_resource_id(full_name) == "12345/locations/eu/instances/my-instance/nativeDashboards/123-ID-abc"
32+
assert format_resource_id(full_name) == "123-ID-abc"
3333

3434

3535
def test_format_resource_id_handles_minimal_projects_prefix() -> None:

0 commit comments

Comments
 (0)