fix: duplicate session commit in step logging (#7512)
* fix: duplicate session commit in step logging * update all callsites
This commit is contained in:
@@ -120,7 +120,8 @@ async def clear_tables():
|
||||
async with db_registry.async_session() as session:
|
||||
await session.execute(delete(SandboxEnvironmentVariable))
|
||||
await session.execute(delete(SandboxConfig))
|
||||
await session.commit() # Commit the deletion
|
||||
# context manager now handles commits
|
||||
# await session.commit()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@@ -43,7 +43,8 @@ async def _clear_tables():
|
||||
if table.name == "block_history":
|
||||
continue
|
||||
await session.execute(table.delete()) # Truncate table
|
||||
await session.commit()
|
||||
# context manager now handles commits
|
||||
# await session.commit()
|
||||
|
||||
|
||||
def _run_server():
|
||||
|
||||
@@ -85,7 +85,8 @@ async def clear_tables():
|
||||
async with db_registry.async_session() as session:
|
||||
await session.execute(delete(SandboxEnvironmentVariable))
|
||||
await session.execute(delete(SandboxConfig))
|
||||
await session.commit() # Commit the deletion
|
||||
# context manager now handles commits
|
||||
# await session.commit()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@@ -53,7 +53,8 @@ async def _clear_tables():
|
||||
async with db_registry.async_session() as session:
|
||||
for table in reversed(Base.metadata.sorted_tables):
|
||||
await session.execute(table.delete())
|
||||
await session.commit()
|
||||
# context manager now handles commits
|
||||
# await session.commit()
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
|
||||
@@ -60,7 +60,8 @@ async def clear_tables():
|
||||
async with db_registry.async_session() as session:
|
||||
await session.execute(delete(SandboxEnvironmentVariable))
|
||||
await session.execute(delete(SandboxConfig))
|
||||
await session.commit() # Commit the deletion
|
||||
# context manager now handles commits
|
||||
# await session.commit()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@@ -2423,7 +2423,8 @@ async def test_list_tools_with_corrupted_tool(server: SyncServer, default_user,
|
||||
)
|
||||
|
||||
session.add(corrupted_tool)
|
||||
await session.commit()
|
||||
# context manager now handles commits
|
||||
# await session.commit()
|
||||
corrupted_tool_id = corrupted_tool.id
|
||||
|
||||
# Now try to list tools - it should still work and not include the corrupted tool
|
||||
|
||||
@@ -79,7 +79,8 @@ def _clear_tables():
|
||||
async with db_registry.async_session() as session:
|
||||
for table in reversed(Base.metadata.sorted_tables): # Reverse to avoid FK issues
|
||||
await session.execute(table.delete()) # Truncate table
|
||||
await session.commit()
|
||||
# context manager now handles commits
|
||||
# await session.commit()
|
||||
|
||||
asyncio.run(_clear())
|
||||
|
||||
|
||||
@@ -43,7 +43,8 @@ async def _clear_tables():
|
||||
async with db_registry.async_session() as session:
|
||||
for table in reversed(Base.metadata.sorted_tables): # Reverse to avoid FK issues
|
||||
await session.execute(table.delete()) # Truncate table
|
||||
await session.commit()
|
||||
# context manager now handles commits
|
||||
# await session.commit()
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
|
||||
@@ -218,7 +218,8 @@ async def clear_tables():
|
||||
async with db_registry.async_session() as session:
|
||||
await session.execute(delete(SandboxEnvironmentVariable))
|
||||
await session.execute(delete(SandboxConfig))
|
||||
await session.commit()
|
||||
# context manager now handles commits
|
||||
# await session.commit()
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -167,7 +167,8 @@ class TestMCPServerEncryption:
|
||||
updated_at=datetime.now(timezone.utc),
|
||||
)
|
||||
session.add(db_server)
|
||||
await session.commit()
|
||||
# context manager now handles commits
|
||||
# await session.commit()
|
||||
|
||||
# Retrieve server directly by ID to avoid issues with other servers in DB
|
||||
test_server = await server.mcp_manager.get_mcp_server_by_id_async(server_id, actor=default_user)
|
||||
@@ -183,7 +184,8 @@ class TestMCPServerEncryption:
|
||||
result = await session.execute(select(ORMMCPServer).where(ORMMCPServer.id == server_id))
|
||||
db_server = result.scalar_one()
|
||||
await session.delete(db_server)
|
||||
await session.commit()
|
||||
# context manager now handles commits
|
||||
# await session.commit()
|
||||
|
||||
finally:
|
||||
# Restore original encryption key
|
||||
@@ -338,7 +340,8 @@ class TestMCPOAuthEncryption:
|
||||
updated_at=datetime.now(timezone.utc),
|
||||
)
|
||||
session.add(db_oauth)
|
||||
await session.commit()
|
||||
# context manager now handles commits
|
||||
# await session.commit()
|
||||
|
||||
# Retrieve through manager by ID
|
||||
test_session = await server.mcp_manager.get_oauth_session_by_id(session_id, actor=default_user)
|
||||
@@ -456,7 +459,8 @@ class TestMCPOAuthEncryption:
|
||||
updated_at=datetime.now(timezone.utc),
|
||||
)
|
||||
session.add(db_oauth)
|
||||
await session.commit()
|
||||
# context manager now handles commits
|
||||
# await session.commit()
|
||||
|
||||
# Retrieve through manager
|
||||
test_session = await server.mcp_manager.get_oauth_session_by_id(session_id, actor=default_user)
|
||||
@@ -505,7 +509,8 @@ class TestMCPOAuthEncryption:
|
||||
updated_at=datetime.now(timezone.utc),
|
||||
)
|
||||
session.add(db_oauth)
|
||||
await session.commit()
|
||||
# context manager now handles commits
|
||||
# await session.commit()
|
||||
|
||||
# Retrieve through manager
|
||||
test_session = await server.mcp_manager.get_oauth_session_by_id(session_id, actor=default_user)
|
||||
|
||||
Reference in New Issue
Block a user