From 50aa88431420ef8a47d390df0009e6d92fc18254 Mon Sep 17 00:00:00 2001 From: Matthew Roberson Date: Fri, 10 Jul 2026 15:37:40 -0500 Subject: [PATCH] Fix foundry _get_app to raise ResourceNotFoundError for missing apps A missing app used to surface from the API as InvalidQueryError, which _get_app mapped to ResourceNotFoundError. The API now returns a generic "not found" LabelboxError instead, so it fell through to the generic wrapper and test_get_app_with_invalid_id (asserting pytest.raises(ResourceNotFoundError)) failed. Detect the not-found LabelboxError and re-raise ResourceNotFoundError, preserving the method's documented contract. ResourceNotFoundError is a subclass of LabelboxError, so other errors still wrap as before. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../labelbox/src/labelbox/schema/foundry/foundry_client.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libs/labelbox/src/labelbox/schema/foundry/foundry_client.py b/libs/labelbox/src/labelbox/schema/foundry/foundry_client.py index a48e7f9c4..7fbdfd792 100644 --- a/libs/labelbox/src/labelbox/schema/foundry/foundry_client.py +++ b/libs/labelbox/src/labelbox/schema/foundry/foundry_client.py @@ -55,6 +55,13 @@ def _get_app(self, id: str) -> App: response = self.client.execute(query_str, params) except exceptions.InvalidQueryError: raise exceptions.ResourceNotFoundError(App, params) + except exceptions.LabelboxError as e: + # A missing app used to surface as InvalidQueryError; the API now + # returns a generic "not found" LabelboxError instead. Map it back + # to ResourceNotFoundError to preserve this method's contract. + if "not found" in str(e).lower(): + raise exceptions.ResourceNotFoundError(App, params) + raise exceptions.LabelboxError(f"Unable to get app with id {id}", e) except Exception as e: raise exceptions.LabelboxError(f"Unable to get app with id {id}", e) return App(**response["findModelFoundryApp"])