Skip to content

Commit 153a0a7

Browse files
Copilotp-
andauthored
Fix parallel test failures: suppress SQLite table creation race condition and add pytest-asyncio dependency
The CI failure was caused by two issues: 1. Module-level Base.metadata.create_all() in gh_file_viewer.py raced when multiple pytest-xdist workers imported the module simultaneously, causing 'table search_results already exists' errors during test collection. 2. pytest-asyncio was missing from test dependencies, which would cause async test functions to fail after collection. Changes: - Wrap create_all() with contextlib.suppress(Exception) to handle concurrent table creation attempts gracefully - Add pytest-asyncio as a hatch-test extra dependency - Set asyncio_mode = "auto" in pytest config Agent-Logs-Url: https://github.com/GitHubSecurityLab/seclab-taskflows/sessions/84c7962f-5966-4924-8617-8378affd1621 Co-authored-by: p- <176818+p-@users.noreply.github.com>
1 parent 90a3b91 commit 153a0a7

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ Issues = "https://github.com/GitHubSecurityLab/seclab-taskflows/issues"
3535
[tool.hatch.version]
3636
path = "src/seclab_taskflows/__about__.py"
3737

38+
[tool.hatch.envs.hatch-test]
39+
extra-dependencies = [
40+
"pytest-asyncio",
41+
]
42+
3843
[tool.hatch.envs.types]
3944
extra-dependencies = [
4045
"mypy>=1.0.0",
@@ -122,6 +127,7 @@ ignore = [
122127
]
123128

124129
[tool.pytest.ini_options]
130+
asyncio_mode = "auto"
125131
markers = [
126132
"xdist_group: Group tests to run on the same xdist worker",
127133
]

src/seclab_taskflows/mcp_servers/gh_file_viewer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import httpx
88
import json
99
import os
10+
import contextlib
1011
from sqlalchemy.orm import DeclarativeBase, mapped_column, Mapped
1112
from sqlalchemy import create_engine
1213
from sqlalchemy.orm import Session
@@ -53,7 +54,8 @@ def __repr__(self):
5354
SEARCH_RESULT_DIR = mcp_data_dir("seclab-taskflows", "gh_file_viewer", "SEARCH_RESULTS_DIR")
5455

5556
engine = create_engine(f"sqlite:///{os.path.abspath(SEARCH_RESULT_DIR)}/search_result.db", echo=False)
56-
Base.metadata.create_all(engine, tables=[SearchResults.__table__])
57+
with contextlib.suppress(Exception):
58+
Base.metadata.create_all(engine, tables=[SearchResults.__table__])
5759

5860

5961
async def call_api(url: str, params: dict) -> str:

0 commit comments

Comments
 (0)