diff --git a/selftests/test_connect_cleanup.py b/selftests/test_connect_cleanup.py index a82bf8cc..39a4dd57 100644 --- a/selftests/test_connect_cleanup.py +++ b/selftests/test_connect_cleanup.py @@ -112,7 +112,7 @@ def handler(request: httpx.Request) -> httpx.Response: if request.method == "GET" and path.endswith("/v1/tags"): return httpx.Response(200, json=[{"id": "t1", "name": "_vip_test"}]) if request.method == "GET" and path.endswith("/v1/tags/t1/content"): - return httpx.Response(200, json={"results": [{"guid": "a"}, {"guid": "b"}]}) + return httpx.Response(200, json=[{"guid": "a"}, {"guid": "b"}]) if request.method == "DELETE": return httpx.Response(200) if request.method == "GET": @@ -127,6 +127,21 @@ def handler(request: httpx.Request) -> httpx.Response: assert ("GET", "/__api__/v1/content/b") in calls +def test_list_vip_content_returns_bare_array_from_tag_content_endpoint(): + """GET /v1/tags/{id}/content returns a bare JSON array, not {"results": [...]}.""" + + def handler(request: httpx.Request) -> httpx.Response: + path = request.url.path + if path.endswith("/v1/tags"): + return httpx.Response(200, json=[{"id": "t1", "name": "_vip_test"}]) + if path.endswith("/v1/tags/t1/content"): + return httpx.Response(200, json=[{"guid": "a"}, {"guid": "b"}]) + return httpx.Response(404) + + cc = _client_with_handler(handler) + assert cc.list_vip_content() == [{"guid": "a"}, {"guid": "b"}] + + def test_cleanup_vip_content_raises_when_tag_lookup_fails(): """A failed tag lookup must raise, not silently report "0 deleted". diff --git a/src/vip/clients/connect.py b/src/vip/clients/connect.py index 025111ed..24d36e15 100644 --- a/src/vip/clients/connect.py +++ b/src/vip/clients/connect.py @@ -278,7 +278,8 @@ def list_vip_content(self) -> list[dict[str, Any]]: tag_id = tags[0]["id"] resp = self._client.get(f"/v1/tags/{tag_id}/content") resp.raise_for_status() - return resp.json().get("results", []) + # Unlike the paginated list endpoints, this returns a bare array. + return resp.json() except Exception as exc: raise ProductUnreachableError(f"could not list VIP-tagged content: {exc}") from exc