Skip to content

fix(api-core): make RetryError picklable - #18963

Closed
yashgupta29032006 wants to merge 5 commits into
googleapis:mainfrom
yashgupta29032006:fix/retry-error-pickling
Closed

yashgupta29032006 wants to merge 5 commits into
googleapis:mainfrom
yashgupta29032006:fix/retry-error-pickling

Conversation

@yashgupta29032006

@yashgupta29032006 yashgupta29032006 commented Nov 3, 2026 •

Copy link
Copy Markdown

Summary

Make google.api_core.exceptions.RetryError support pickling and copying.

Changes

  • Implement RetryError.__reduce__() to reconstruct the exception with both its message and cause.
  • Add regression tests for pickle, shallow copy, and deep copy, including a None cause.

Testing

  • pytest tests/unit/test_exceptions.py -q
  • pytest tests/unit -W "ignore::pytest.PytestDeprecationWarning" -q
  • pytest tests/asyncio -W "ignore::pytest.PytestDeprecationWarning" -q

Fixes #18946

@yashgupta29032006
yashgupta29032006 requested review from a team as code owners November 3, 2026 13:48

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements a __reduce__ method in google/api_core/exceptions.py to support pickling and copying of exception objects, adds corresponding unit tests, and updates docstrings in the Firestore client. The review feedback correctly points out that the current __reduce__ implementation only returns a 2-tuple, which would discard other instance attributes stored in __dict__. It is recommended to return a 3-tuple containing self.__dict__ to preserve all state, and to update the unit tests to verify that custom attributes are retained and that shallow copying preserves object identity for the exception's cause.

@yashgupta29032006

Copy link
Copy Markdown
Author

Hi maintainers, I’ve opened this PR to address issue #18946 by making RetryError support pickling and copying, with regression tests included. The required multi-approvers check is currently failing because it requires internal approvals. Could someone please review the changes when convenient? Thank you!

@parthea

parthea commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Closing as #18947 also addresses the same issue

@parthea parthea closed this Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants