UNPKG

@debugmcp/mcp-debugger

Version:

Run-time step-through debugging for LLM agents.

96 lines (72 loc) 4.12 kB
# Task 26: Fix Test Failures Revealed by Skip Logic Fix - Summary ## Overview Task 25 successfully fixed the inverted skip logic, causing tests to run by default. This revealed 3 failing tests that were previously hidden. All failures were related to container path handling in Docker environments. ## Test Status Before Fix - **805 tests passing** - **3 tests failing** (all container-related) - **1 test still skipped** ## Test Status After Fix - **808 tests passing** (+3) - **0 tests failing** - **0 tests skipped** (removed the obsolete Python discovery test) ## Root Causes Identified ### 1. Container Working Directory Mismatch The Dockerfile sets `WORKDIR /app`, but test volumes are mounted at `/workspace`. This caused path resolution failures. ### 2. Proxy Worker Path Validation The proxy worker was checking if script paths exist from the container's working directory (`/app`) instead of the mounted volume location (`/workspace`). ### 3. DAP Launch Request Path Issues The `sendLaunchRequest` was using relative paths and incorrect working directories in container mode. ### 4. Python Debug Target Working Directory The debug target launcher wasn't using the correct working directory in container mode. ## Fixes Applied ### 1. Process Launcher Implementation (`src/implementations/process-launcher-impl.ts`) ```typescript // Fixed working directory for container mode const cwd = process.env.MCP_CONTAINER === 'true' ? '/workspace' // Use mounted volume directory : path.dirname(scriptPath); ``` ### 2. Proxy Worker Path Validation (`src/proxy/dap-proxy-worker.ts`) ```typescript // Check paths relative to /workspace in container mode let scriptToCheck = payload.scriptPath; if (process.env.MCP_CONTAINER === 'true' && !path.isAbsolute(payload.scriptPath)) { scriptToCheck = path.join('/workspace', payload.scriptPath); } ``` ### 3. DAP Connection Manager (`src/proxy/dap-proxy-connection-manager.ts`) ```typescript // Convert relative paths to absolute and use correct working directory if (process.env.MCP_CONTAINER === 'true') { if (!path.isAbsolute(scriptPath)) { programPath = path.join('/workspace', scriptPath); } workingDir = '/workspace'; } ``` ## Container Path Resolution Strategy The fix establishes a consistent path resolution strategy for container mode: 1. **Working Directory**: Always use `/workspace` as the working directory in containers 2. **Path Validation**: Check file existence relative to `/workspace` for relative paths 3. **Absolute Paths**: Convert relative paths to absolute paths anchored at `/workspace` 4. **Volume Mounts**: Ensure all volume mounts use `/workspace` as the container mount point ## Test Results ### Fixed Tests 1. **Container fibonacci.py test**: Now correctly resolves `examples/python/fibonacci.py` to `/workspace/examples/python/fibonacci.py` 2. **Container absolute path rejection test**: Now properly rejects absolute host paths while accepting relative paths 3. **SSE server temp directory test**: Now passes (was previously passing, counted in the 808) ### Remaining Work - None - all test issues have been resolved - Deleted the obsolete Python discovery test that was previously skipped ## Lessons Learned 1. **Container Path Consistency**: It's critical to maintain consistency between Dockerfile WORKDIR and volume mount points 2. **Path Resolution Logic**: Container mode requires special handling for path resolution at multiple layers 3. **Test Skip Logic**: Incorrect skip logic can hide failing tests, making it important to regularly audit skip conditions 4. **Relative vs Absolute Paths**: Container environments need clear rules about when to use relative vs absolute paths ## Impact This fix ensures that the MCP debugger works correctly in containerized environments, which is essential for: - Docker-based development workflows - CI/CD pipelines using containers - Cross-platform debugging scenarios - Isolated debugging environments The fixes make the container path handling more robust and predictable, reducing the likelihood of path-related issues in production container deployments.