From e23dcdf4e1b1d1c0d541dd1807872c9e1fafa3a9 Mon Sep 17 00:00:00 2001 From: Alex Blank Date: Wed, 27 May 2026 15:33:06 +0200 Subject: [PATCH] fix: remove broken ~ expansion, require working_directory for relative paths --- apps/api/src/api/tool_instances.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/apps/api/src/api/tool_instances.py b/apps/api/src/api/tool_instances.py index 5ba0134..47dc53a 100644 --- a/apps/api/src/api/tool_instances.py +++ b/apps/api/src/api/tool_instances.py @@ -110,17 +110,16 @@ async def _resolve_single_git_mount( logger.warning("Invalid git mount skipped: missing remote_url or target_path") return [] - # Expand ~ to the working directory or a default home path - # (The container may have HOME set to /tmp, so we resolve it ourselves) - if target_path.startswith("~"): - home = working_directory or "/home/user" - target_path = home + target_path[1:] - logger.info("Expanded ~ to %s", target_path) - # Resolve relative target paths against working directory if target_path and not target_path.startswith("/"): - base = working_directory or "/home/user" - target_path = os.path.join(base, target_path) + if not working_directory: + logger.warning( + "Git mount skipped: target_path '%s' is relative but no working_directory is configured. " + "Set working_directory in the tool config or use an absolute path.", + target_path + ) + return [] + target_path = os.path.join(working_directory, target_path) logger.info("Resolved relative target path to %s", target_path) if not instance_dir: