fix(application-integration): fail on errored or stuck schema operations - #7167
Open
1aifanatic wants to merge 1 commit into
Open
1aifanatic wants to merge 1 commit into
1aifanatic wants to merge 1 commit into
Conversation
|
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. |
ConnectionsClient._poll_operation() only looked at `done`. A finished operation carrying `error` (a mistyped entity or action, a missing permission) was returned as a success, so ApplicationIntegrationToolset built silently with no tools, or with tools against an empty schema. The loop also had no deadline, so an operation that never finished blocked toolset construction indefinitely, and it slept once more after the operation was already done. Raise ValueError with the operation's error message, bound the wait with a TimeoutError after _DEFAULT_OPERATION_TIMEOUT_SECONDS, and stop sleeping once the operation is done. Fixes google#7165 Claude-Session: https://claude.ai/code/session_013vXxD1ga1hnCq2uFRwNks7
1aifanatic
force-pushed
the
fix/connections-client-poll-operation-errors
branch
from
September 19, 2026 05:31
5d47aaa to
933f898
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
Problem:
ConnectionsClient._poll_operation(), whichApplicationIntegrationToolsetuses to fetch entity and action schemas, only checkeddone:errorinstead ofresponse(a mistyped entity or action, or a missing permission on the connection) was returned as if it had succeeded. The callers then fell back to an empty schema and no operations, so the toolset built silently with no tools for that entity, or with tools against an empty schema. A failed action produced a tool with an empty display name.Solution:
errornow raisesValueError("Operation <id> failed: <message>").ValueErroris whatget_entity_schema_and_operations/get_action_schemaalready document for request and processing errors, so it surfaces from toolset construction._DEFAULT_OPERATION_TIMEOUT_SECONDS(300 s, set next to the existing_DEFAULT_REQUEST_TIMEOUT_SECONDS) and raisesTimeoutErrorwhen exceeded.doneis set. As a side effect, the existing success tests no longer spend a real second each intime.sleep.Testing Plan
Unit Tests:
New tests in
test_connections_client.py:test_get_entity_schema_and_operations_failed_operation: adone+erroroperation raises with the server's message. Fails onmain.test_poll_operation_times_out: an operation that never finishes raisesTimeoutErroronce the deadline passes (timeis mocked). Onmainit never returns.test_poll_operation_does_not_sleep_once_done. Fails onmain.None of the failures are in
tools/. All of them also fail on an unmodifiedorigin/maincheckout on the same machine: 40 deterministically (Windows-specific tests incli/deploy, conformance,scripts/check_new_py_files, path normalization, the unsafe local code executor, the import allowlist, and yaml), and the rest aretelemetry/test_functional.py/test_node_functional.py/test_auto_tracing_plugin.pycases that are flaky here. I ran those eight 3 times on cleanmainand they failed 3, 0 and 3 times, versus 1 to 4 on this branch. I ran on Python 3.12 only, not the fulltoxmatrix.Manual End-to-End (E2E) Tests:
A real
ApplicationIntegrationToolset(connection=..., entity_operations={"Acount": []})built against stubbed Connectors HTTP, where thegetEntityTypeoperation finishes with{"done": true, "error": {"code": 5, "message": "Entity type 'Acount' not found."}}. The script is in #7165.Before (
main):After (this branch):
Checklist
Additional context
I picked 300 s so slow schema lookups on large connectors don't fail spuriously. I'm happy to change it if you have a better number from the service side.
🤖 Generated with Claude Code
https://claude.ai/code/session_013vXxD1ga1hnCq2uFRwNks7