fix(session): reject read_session match-all patterns

This commit is contained in:
chengyongru
2026-08-26 16:58:29 +08:00
committed by chengyongru
parent 23dc344b8d
commit c62aec0175
2 changed files with 24 additions and 10 deletions
+15 -1
View File
@@ -236,7 +236,7 @@ async def test_read_session_filters_by_query_and_returns_recent_matches(tmp_path
@pytest.mark.asyncio
@pytest.mark.parametrize("query", [None, "", " ", "*", ".*"])
@pytest.mark.parametrize("query", [None, "", " "])
async def test_read_session_accepts_unfiltered_query_forms(tmp_path, query):
manager = SessionManager(tmp_path)
_save_session(
@@ -262,6 +262,20 @@ async def test_read_session_accepts_unfiltered_query_forms(tmp_path, query):
]
@pytest.mark.asyncio
@pytest.mark.parametrize("query", ["*", ".*"])
async def test_read_session_rejects_match_all_patterns_with_retry_guidance(tmp_path, query):
with _webui_request():
result = await ReadSessionTool(SessionManager(tmp_path)).execute(
session_key="websocket:history",
query=query,
)
assert result.is_error
assert "literal substring" in str(result)
assert "Omit query" in str(result)
@pytest.mark.asyncio
async def test_read_session_reports_invalid_requests(tmp_path):
with _webui_request():