From f84c2597fa301ac1bb91c437a209d57317c6dda6 Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Sun, 2 Nov 2025 11:03:45 -0800 Subject: [PATCH] Improve set_context timeout handling - fail instead of guessing path - Increase timeout to 5s for slow git operations - Return error instead of falling back to unverified path - Prevents accidental .beads creation in wrong directory --- integrations/beads-mcp/src/beads_mcp/server.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/integrations/beads-mcp/src/beads_mcp/server.py b/integrations/beads-mcp/src/beads_mcp/server.py index 7bc2afc5..f966007e 100644 --- a/integrations/beads-mcp/src/beads_mcp/server.py +++ b/integrations/beads-mcp/src/beads_mcp/server.py @@ -233,11 +233,16 @@ async def set_context(workspace_root: str) -> str: try: resolved_root = await asyncio.wait_for( asyncio.to_thread(_resolve_workspace_root, workspace_root), - timeout=2.0, + timeout=5.0, # Longer timeout to handle slow git operations ) except asyncio.TimeoutError: - logger.warning(f"Git detection timed out, using provided path: {workspace_root}") - resolved_root = os.path.abspath(workspace_root) + logger.error(f"Git detection timed out after 5s for: {workspace_root}") + return ( + f"Error: Git repository detection timed out.\n" + f" Provided path: {workspace_root}\n" + f" This may indicate a slow filesystem or git configuration issue.\n" + f" Please ensure the path is correct and git is responsive." + ) # Always set working directory and context flag os.environ["BEADS_WORKING_DIR"] = resolved_root