fix: prevent double translation of already-translated Docker paths
Added check in translate_path_for_environment() to detect and skip already-translated container paths (those starting with /workspace). This prevents the function from attempting to translate paths like: - /workspace/src/main.py -> /inaccessible/outside/mounted/volume/workspace/src/main.py Now it correctly handles: - Host path: /Users/.../src/main.py -> /workspace/src/main.py (translation) - Container path: /workspace/src/main.py -> /workspace/src/main.py (no change) Added comprehensive test to verify double-translation prevention. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -195,6 +195,11 @@ def translate_path_for_environment(path_str: str) -> str:
|
||||
# Not in the configured Docker environment, no translation needed
|
||||
return path_str
|
||||
|
||||
# Check if the path is already a container path (starts with /workspace)
|
||||
if path_str.startswith(str(CONTAINER_WORKSPACE) + "/") or path_str == str(CONTAINER_WORKSPACE):
|
||||
# Path is already translated to container format, return as-is
|
||||
return path_str
|
||||
|
||||
try:
|
||||
# Use os.path.realpath for security - it resolves symlinks completely
|
||||
# This prevents symlink attacks that could escape the workspace
|
||||
|
||||
Reference in New Issue
Block a user