Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,8 @@ ignore = [
"S101", # Use of assert (standard in pytest)
"SLF001", # Private member accessed (tests legitimately access module internals)
]

[tool.pytest.ini_options]
markers = [
"xdist_group: Group tests to run on the same xdist worker",
]
13 changes: 10 additions & 3 deletions src/seclab_taskflows/mcp_servers/gh_file_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ def __repr__(self):
SEARCH_RESULT_DIR = mcp_data_dir("seclab-taskflows", "gh_file_viewer", "SEARCH_RESULTS_DIR")

engine = create_engine(f"sqlite:///{os.path.abspath(SEARCH_RESULT_DIR)}/search_result.db", echo=False)
Base.metadata.create_all(engine, tables=[SearchResults.__table__])

try:
Base.metadata.create_all(engine, tables=[SearchResults.__table__])
except Exception as e:
logging.exception(f"Database already exists") # only log here, as this error likely only happens in test
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

The module-level try/except around Base.metadata.create_all(...) catches all exceptions and then continues, which can hide real database setup failures (e.g., missing/invalid DB path, permission issues) and lead to later runtime errors when writing/querying. If this is meant to tolerate a known concurrent-create race, catch the specific SQLAlchemy exception(s) and only ignore the specific "already exists" case; otherwise re-raise after logging. Also, the log message "Database already exists" is misleading for most exceptions coming from create_all.

Copilot uses AI. Check for mistakes.


async def call_api(url: str, params: dict) -> str:
Expand Down Expand Up @@ -283,10 +287,13 @@ async def list_directory_from_gh(
r = await call_api(url=f"https://api.github.com/repos/{owner}/{repo}/contents/{path}", params={})
if isinstance(r, str):
return r
if not r.json():
data = r.json()
if not data:
return json.dumps([], indent=2)
if not isinstance(data, list):
return f"Path '{path}' is not a directory."

content = [item["path"] for item in r.json()]
content = [item["path"] for item in data]
return json.dumps(content, indent=2)


Expand Down
Loading
Loading