Skip to content

fix: initialize payloads before try block in _flush_events#112

Open
jonathannorris wants to merge 1 commit intomainfrom
fix/unbound-local-error-flush-events
Open

fix: initialize payloads before try block in _flush_events#112
jonathannorris wants to merge 1 commit intomainfrom
fix/unbound-local-error-flush-events

Conversation

@jonathannorris
Copy link
Copy Markdown
Member

Summary

  • Initializes payloads = [] before the try block in _flush_events so a flush_event_queue() exception (e.g. a WASM trap) no longer causes UnboundLocalError: local variable 'payloads' referenced before assignment on the subsequent if payloads: check
  • Adds a regression test covering this path

Related Issues

Fixes #111

Prevents UnboundLocalError when flush_event_queue() raises (e.g. a WASM
trap), which previously masked the original error. Adds a regression test.

Fixes #111
Copilot AI review requested due to automatic review settings May 4, 2026 19:45
@jonathannorris jonathannorris requested a review from a team as a code owner May 4, 2026 19:45
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a latent UnboundLocalError in EventQueueManager._flush_events() by ensuring payloads is always defined even when flush_event_queue() raises (e.g., WASM trap), and adds a regression test to cover the exception path (Fixes #111).

Changes:

  • Initialize payloads = [] before the try block in _flush_events to prevent UnboundLocalError after exceptions.
  • Add a unit test asserting _flush_events() returns 0 and does not attempt to publish when flush_event_queue() raises.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
devcycle_python_sdk/managers/event_queue_manager.py Prevents UnboundLocalError by initializing payloads prior to the try/except around flush_event_queue().
test/managers/test_event_queue_manager.py Adds regression coverage for the exception path to ensure _flush_events() safely returns 0 and does not publish.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

UnboundLocalError in _flush_events masks WASM trap errors

3 participants