From f44cf8b1dd8ffe33dbb0db7a3f1dd31f382da373 Mon Sep 17 00:00:00 2001 From: Sycun <165354365+Sycun@users.noreply.github.com> Date: Thu, 12 Nov 2026 21:29:58 +0800 Subject: [PATCH] test(pi): inject invalid persisted root after path validation --- internal/database/pi_sessions_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/database/pi_sessions_test.go b/internal/database/pi_sessions_test.go index ee8f64dd..36bcc566 100644 --- a/internal/database/pi_sessions_test.go +++ b/internal/database/pi_sessions_test.go @@ -110,11 +110,11 @@ func TestDeleteTurnRollsBackWhenPiCleanupFails(t *testing.T) { if err != nil { t.Fatal(err) } - // A regular file as the parent is treated as an absent target by Windows - // RemoveAll. NUL is invalid on every supported OS and reliably exercises - // the cleanup error/transaction rollback path without filesystem privileges. + // Simulate an unusable persisted root. Inject it directly because Windows + // rejects NUL in filepath.Abs before registration, while Unix rejects it + // during removal. This reaches cleanup on both systems without privileges. blocked := filepath.Join(root, "invalid\x00root") - if err := db.SetAgentSessionDir(blocked); err != nil { + if _, err := db.Exec(`INSERT INTO pi_session_roots (path) VALUES (?)`, blocked); err != nil { t.Fatal(err) } if _, err := db.DeleteConversationTurn(conv.ID, msg.ID); err == nil {