Skip to content

Commit b3ff46e

Browse files
committed
docs: add comment documenting divergence from JS SDK
1 parent bbe9591 commit b3ff46e

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/firebase_functions/logger.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ def _stack_trace_from_exception(exception: BaseException) -> str | None:
8888
_traceback.format_exception(exception.__class__, exception, exception.__traceback__)
8989
)
9090
except Exception:
91+
92+
# We intentionally divergence from the JS SDK here:
93+
# JS stores error traces in `message`, but Python emits a top-level `stack_trace`
94+
# because Google Cloud Error Reporting only inspects top-level error fields
95+
# (`stack_trace`, `exception`, `message`). Do not move this trace under `error`
96+
# or fold it back into nested payloads, or Error Reporting may stop detecting it.
97+
9198
stack_trace = "".join(_traceback.format_tb(exception.__traceback__))
9299
stack_trace += f"{exception.__class__.__name__}: {_safe_exception_string(exception)}\n"
93100
return stack_trace
@@ -106,6 +113,7 @@ def _stack_trace_from_exception_type(exception_type: type[BaseException]) -> str
106113
return None
107114

108115

116+
109117
def _stack_trace_from_args(
110118
args: tuple[_typing.Any, ...], kwargs: dict[str, _typing.Any]
111119
) -> str | None:

0 commit comments

Comments
 (0)