Skip to content

Commit 72265ff

Browse files
committed
feat(fdc): Add TODO for partial errors and include response payload in error message
Added a TODO comment referencing b/406281627 for partial errors support in ExecuteGraphqlResponse and _parse_graphql_response. Updated _parse_graphql_response to include the raw response payload in the InternalError message string for improved debug visibility.
1 parent 28a50e2 commit 72265ff

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

firebase_admin/dataconnect.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import typing
2424
from typing import Any, Dict, Generic, Optional, Type, TypeVar, Union
2525

26-
2726
import requests
2827

2928
import firebase_admin
@@ -195,11 +194,18 @@ class GraphqlOptions(Generic[_Variables]):
195194
impersonate: Optional[Union[Impersonation, Dict[str, Any]]] = None
196195

197196

197+
# TODO(b/406281627): Add support for partial errors.
198198
@dataclass
199199
class ExecuteGraphqlResponse(Generic[_Data]):
200+
"""Represents the response from a DataConnect GraphQL execution.
201+
202+
Attributes:
203+
data: The raw JSON dictionary returned by the GraphQL execution.
204+
"""
200205
data: _Data
201206

202207

208+
203209
def _get_emulator_host() -> Optional[str]:
204210
return _utils.get_emulator_host("DATA_CONNECT_EMULATOR_HOST")
205211

@@ -410,7 +416,8 @@ def _parse_graphql_response(
410416
"""Parses a raw GraphQL response payload into ExecuteGraphqlResponse."""
411417
if not isinstance(resp_dict, dict):
412418
raise exceptions.InternalError(
413-
message="Response payload is not a valid JSON dictionary."
419+
message=f"Response payload is not a valid JSON dictionary: {resp_dict}"
414420
)
415421

422+
# TODO(b/406281627): Add support for partial errors.
416423
return ExecuteGraphqlResponse(data=resp_dict.get("data"))

tests/test_data_connect.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,4 +880,6 @@ def test_parse_graphql_response_non_dict_error(self):
880880
self.api_client._parse_graphql_response("not-a-dict")
881881

882882
assert excinfo.value.code == exceptions.INTERNAL
883-
assert str(excinfo.value) == "Response payload is not a valid JSON dictionary."
883+
assert str(excinfo.value) == (
884+
"Response payload is not a valid JSON dictionary: not-a-dict"
885+
)

0 commit comments

Comments
 (0)