Skip to content

fix(google-api-core): report background polling failures - #18863

Open
JackyHsu-X wants to merge 1 commit into
googleapis:mainfrom
JackyHsu-X:fix/async-polling-failure
Open

JackyHsu-X wants to merge 1 commit into
googleapis:mainfrom
JackyHsu-X:fix/async-polling-failure

Conversation

@JackyHsu-X

Copy link
Copy Markdown

When an AsyncOperation refresh raises a non-retryable error such as Forbidden, background polling fails without resolving the future. Completion callbacks never run, leaving callback-based callers waiting indefinitely.

Run background polling through a wrapper that stores ordinary polling exceptions on the future. This notifies existing callbacks and makes the original error available through result() and exception(). Preserve an already completed future, foreground polling behavior, and task cancellation.

Regression coverage includes both the base future and an actual AsyncOperation, plus completion racing with a polling failure and cancellation. On unchanged code, the two affected test modules have 4 failures and 22 passes; with the fix, all 26 pass.

Validation on Windows:

  • Python 3.13, full google-api-core unit and asyncio suites: 1,643 passed, 1 skipped.
  • Python 3.10 with the package's minimum-dependency constraints: 1,507 passed, 91 skipped.
  • Python 3.13 without gRPC: 1,150 passed, 28 skipped.
  • Combined package statement/branch coverage: 100%. Mypy, Flake8, and the applicable repository pre-commit hooks pass.

Cloud system tests, other packages in the monorepo, and other operating systems were not run locally.

  • Make sure to open an issue before writing your code.
  • Ensure the tests and linter pass.
  • Code coverage does not decrease.
  • Appropriate docs were updated (callback docstring).

Fixes #18862 🦕

AI assistance: OpenAI Codex investigated, generated and self-reviewed the patch, and ran the local checks under the account owner's authorization. No separate human review is claimed.

Assisted-by: OpenAI Codex <noreply@openai.com>
@JackyHsu-X
JackyHsu-X requested a review from a team as a code owner October 27, 2026 08:42
@google-cla

google-cla Bot commented Oct 27, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@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 introduces a new _background_poll helper method in AsyncFuture to handle background polling failures by catching exceptions and setting them on the future, ensuring that registered callbacks are correctly invoked when background polling fails. It also includes comprehensive unit tests to verify error handling during background polling, cancelled polling, and foreground polling. There are no review comments to address, and I have no additional feedback to provide.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AsyncFuture background polling failures leave completion callbacks pending

1 participant