mirror of
https://github.com/AstrBotDevs/AstrBot.git
synced 2026-10-16 06:58:51 +08:00
fix: skip missing default roots in local grep
This commit is contained in:
@@ -800,6 +800,7 @@ class GrepTool(FunctionTool):
|
||||
return [
|
||||
str(root)
|
||||
for root in _read_allowed_roots(umo, current_workspace_root)
|
||||
if root.exists()
|
||||
]
|
||||
if local_env:
|
||||
return [str(current_workspace_root or _workspace_root(umo))]
|
||||
|
||||
@@ -750,12 +750,18 @@ async def test_restricted_local_edit_reuses_first_opened_file(
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("path", ["target.txt", None])
|
||||
async def test_restricted_local_grep_requests_read_only_os_sandbox(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
tmp_path,
|
||||
path,
|
||||
):
|
||||
workspace = _setup_local_fs_tools(monkeypatch, tmp_path)
|
||||
(workspace / "target.txt").write_text("needle\n", encoding="utf-8")
|
||||
missing_root = tmp_path / "missing-temp"
|
||||
monkeypatch.setattr(
|
||||
fs_tools, "_read_allowed_roots", lambda *args: (workspace, missing_root)
|
||||
)
|
||||
calls = []
|
||||
|
||||
class _RecordingFileSystem:
|
||||
@@ -776,10 +782,12 @@ async def test_restricted_local_grep_requests_read_only_os_sandbox(
|
||||
local_permissions={"member": {"filesystem_scope": "workspace"}},
|
||||
),
|
||||
pattern="needle",
|
||||
path="target.txt",
|
||||
path=path,
|
||||
)
|
||||
|
||||
assert "needle" in result
|
||||
assert len(calls) == 1
|
||||
assert not missing_root.exists()
|
||||
assert calls[0]["sandboxed"] is True
|
||||
assert calls[0]["sandbox_root"] == str(workspace)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user