From f9fd556b7c13d3a1108fbed78c418e3163687d44 Mon Sep 17 00:00:00 2001 From: Christine Yu Date: Thu, 19 Feb 2026 15:59:52 -0500 Subject: [PATCH] Fix User.app() to return actual server data instead of empty values Bug: User.app() was fetching app data from server but ignoring response.app and returning an App with only app_id and default/empty values. Fix: Use app.app_info.CopyFrom(response.app) to directly copy the protobuf from server, preserving all fields including enums (e.g., visibility=10). Test: Added test_get_app() to verify visibility and description are correctly retrieved from server. Co-Authored-By: Claude Sonnet 4.5 --- clarifai/client/user.py | 5 ++++- tests/test_app.py | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/clarifai/client/user.py b/clarifai/client/user.py index 67d05678..3d8d42ce 100644 --- a/clarifai/client/user.py +++ b/clarifai/client/user.py @@ -361,7 +361,10 @@ def app(self, app_id: str, **kwargs) -> App: raise Exception(response.status) kwargs['user_id'] = self.id - return App.from_auth_helper(auth=self.auth_helper, app_id=app_id, **kwargs) + kwargs['app_id'] = app_id + app = App.from_auth_helper(auth=self.auth_helper, **kwargs) + app.app_info.CopyFrom(response.app) + return app def runner(self, runner_id: str) -> dict: """Returns a Runner object if exists. diff --git a/tests/test_app.py b/tests/test_app.py index a5a3caf1..26cabdf1 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -173,6 +173,17 @@ def test_patch_app(self, create_client, caplog): ) assert "SUCCESS" in caplog.text + def test_get_app(self, create_client): + # Verify that user.app() returns actual server data, not empty/default values + app = create_client.app(app_id=CREATE_APP_ID) + # These should match what was set in test_patch_app + assert app.app_info.visibility.gettable == 10, ( + f"Expected visibility 10, got {app.app_info.visibility.gettable}" + ) + assert app.app_info.description == 'App Patching Test', ( + f"Expected description 'App Patching Test', got '{app.app_info.description}'" + ) + def test_patch_dataset(self, create_app, caplog): with caplog.at_level(logging.INFO): create_app.patch_dataset(