Skip to content
This repository was archived by the owner on Sep 3, 2025. It is now read-only.

Conversation

@whitdog47
Copy link
Contributor

@whitdog47 whitdog47 commented May 20, 2025

This PR fixes a potential transaction issue by removing a redundant commit in the create_signal_instance function, since commit behavior is already managed by the nested context manager.

Context:

This context manager calls create_signal_instance

for message in response["Messages"]:
    ...
                    with db_session.begin_nested():
                        signal_instance = signal_service.create_signal_instance(
                            db_session=db_session,
                            signal_instance_in=signal_instance_in,
                        )

but at the end of that function we commit the transaction

def create_signal_instance(*, db_session: Session, signal_instance_in: SignalInstanceCreate):
    ...
    db_session.commit()

    return signal_instance 

but with being_nested(), the committing should be handled by the context manager so this commit() leaves the session in an undefined state and could close the transaction.

…stance

The commit operation was removed from the `create_signal_instance` function as it was redundant and unnecessary for the operation.
@whitdog47 whitdog47 requested review from Copilot and wssheldon May 20, 2025 04:59
Copy link
Contributor

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

This PR fixes a potential transaction issue by removing a redundant commit in the create_signal_instance function, since commit behavior is already managed by the nested context manager.

  • Removes the extra db_session.commit() call in create_signal_instance.
  • Ensures that the transaction remains valid under begin_nested() usage.
Comments suppressed due to low confidence (1)

src/dispatch/signal/service.py:195

  • The removal of the db_session.commit() call is necessary because the commit is already managed by the context manager using begin_nested(), avoiding potential undefined session states.
db_session.commit()

@whitdog47 whitdog47 self-assigned this May 20, 2025
@whitdog47 whitdog47 added the bug Something isn't working label May 20, 2025
@whitdog47 whitdog47 merged commit 0067eaf into main May 20, 2025
9 checks passed
@whitdog47 whitdog47 deleted the fix/signal-context-already-managed branch May 20, 2025 16:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants