Skip to content

fix: make event queue sink removal idempotent#1134

Open
dorlugasigal wants to merge 2 commits into
a2aproject:mainfrom
dorlugasigal:fix/idempotent-event-queue-sink-close
Open

fix: make event queue sink removal idempotent#1134
dorlugasigal wants to merge 2 commits into
a2aproject:mainfrom
dorlugasigal:fix/idempotent-event-queue-sink-close

Conversation

@dorlugasigal

Copy link
Copy Markdown

Description

Thank you for opening a Pull Request!

This pull request changed EventQueueSource.remove_sink() to use
set.discard(), so removing an already-absent sink completes without raising
KeyError. EventQueueSink.close() now delegates directly to that idempotent
operation instead of suppressing the exception after telemetry has recorded it.
A regression test closes the same sink twice and verifies that the mocked
OpenTelemetry span records neither an exception nor an error description.

Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Follow the CONTRIBUTING Guide.
  • Make your Pull Request title in the https://www.conventionalcommits.org/ specification.
    • Important Prefixes for release-please:
      • fix: which represents bug fixes, and correlates to a SemVer patch.
      • feat: represents a new feature, and correlates to a SemVer minor.
      • feat!:, or fix!:, refactor!:, etc., which represent a breaking change (indicated by the !) and will result in a SemVer major.
  • Ensure the tests and linter pass (Run bash scripts/format.sh from the repository root to format)
  • Appropriate docs were updated (if necessary)

Fixes #1133 🦕

Use set.discard so repeated sink closure does not raise inside the traced
remove_sink method and export a false ERROR span.

Fixes a2aproject#1133

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 42ca73c6-08fb-4954-96f4-b7e32e46613a
@dorlugasigal dorlugasigal requested a review from a team as a code owner July 13, 2026 15:53

@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 refactors the remove_sink method in EventQueueSource to use discard instead of remove, making the operation idempotent and allowing the removal of a contextlib.suppress(KeyError) block in the close method. A new test is added to verify that closing a sink multiple times does not record exceptions on the telemetry span. The review feedback suggests asserting that the tracer mock's start_as_current_span method was actually called to prevent a vacuous test pass if the mock is not active during execution.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread tests/server/events/test_event_queue_v2.py
@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown

🧪 Code Coverage (vs main)

⬇️ Download Full Report

Base PR Delta
src/a2a/server/events/event_queue_v2.py 91.19% 91.15% 🔴 -0.05%
Total 92.95% 92.95% ⚪️ -0.00%

Generated by coverage-comment.yml

Assert that span creation uses the patched tracer so the regression cannot
pass silently if telemetry instrumentation changes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 42ca73c6-08fb-4954-96f4-b7e32e46613a
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.

[Bug]: Idempotent EventQueueSink.close records KeyError as ERROR span

1 participant