Skip to content

fix(application-integration): fail on errored or stuck schema operations - #7167

Open
1aifanatic wants to merge 1 commit into
google:mainfrom
1aifanatic:fix/connections-client-poll-operation-errors
Open

1aifanatic wants to merge 1 commit into
google:mainfrom
1aifanatic:fix/connections-client-poll-operation-errors

Conversation

@1aifanatic

Copy link
Copy Markdown

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

Problem:

ConnectionsClient._poll_operation(), which ApplicationIntegrationToolset uses to fetch entity and action schemas, only checked done:

  1. A finished operation that carries error instead of response (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.
  2. The loop had no deadline, so an operation that never finishes blocked toolset construction, and therefore agent startup, indefinitely. bf4143a bounded the individual HTTP calls in this client for the same reason; the polling loop around them was still open-ended.
  3. It slept one more second after the operation was already done.

Solution:

  • A finished operation with error now raises ValueError("Operation <id> failed: <message>"). ValueError is what get_entity_schema_and_operations / get_action_schema already document for request and processing errors, so it surfaces from toolset construction.
  • The wait is bounded by _DEFAULT_OPERATION_TIMEOUT_SECONDS (300 s, set next to the existing _DEFAULT_REQUEST_TIMEOUT_SECONDS) and raises TimeoutError when exceeded.
  • There's no sleep once done is set. As a side effect, the existing success tests no longer spend a real second each in time.sleep.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

New tests in test_connections_client.py:

  • test_get_entity_schema_and_operations_failed_operation: a done + error operation raises with the server's message. Fails on main.
  • test_poll_operation_times_out: an operation that never finishes raises TimeoutError once the deadline passes (time is mocked). On main it never returns.
  • test_poll_operation_does_not_sleep_once_done. Fails on main.
$ pytest tests/unittests/tools/application_integration_tool
81 passed

$ pytest tests/unittests/tools -n 4
2308 passed, 2 skipped
$ pytest tests/unittests -n 8   # Python 3.12, Windows 11
41 failed, 15072 passed, 102 skipped, 27 xfailed, 2 xpassed

None of the failures are in tools/. All of them also fail on an unmodified origin/main checkout on the same machine: 40 deterministically (Windows-specific tests in cli/ deploy, conformance, scripts/check_new_py_files, path normalization, the unsafe local code executor, the import allowlist, and yaml), and the rest are telemetry/test_functional.py / test_node_functional.py / test_auto_tracing_plugin.py cases that are flaky here. I ran those eight 3 times on clean main and they failed 3, 0 and 3 times, versus 1 to 4 on this branch. I ran on Python 3.12 only, not the full tox matrix.

Manual End-to-End (E2E) Tests:

A real ApplicationIntegrationToolset(connection=..., entity_operations={"Acount": []}) built against stubbed Connectors HTTP, where the getEntityType operation finishes with {"done": true, "error": {"code": 5, "message": "Entity type 'Acount' not found."}}. The script is in #7165.

Before (main):

toolset built; tools: []
elapsed: 1.0s

After (this branch):

toolset raised: ValueError - Operation operations/op-1 failed: Entity type 'Acount' not found.
elapsed: 0.0s

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

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

@google-cla

google-cla Bot commented Sep 18, 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.

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
1aifanatic force-pushed the fix/connections-client-poll-operation-errors branch from 5d47aaa to 933f898 Compare September 19, 2026 05:31
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.

ApplicationIntegrationToolset silently builds no tools when a Connectors schema operation fails, and waits forever on one that never finishes

2 participants