From d3e22906a8563099a9b758e82b0e7ef2e8347d61 Mon Sep 17 00:00:00 2001 From: "zhangyu.34" Date: Mon, 24 Aug 2026 20:19:15 +0800 Subject: [PATCH] fix(core): ignore blank task list filters Co-Authored-By: Claude Sonnet 4.6 --- packages/core/src/tools/task-list.test.ts | 30 +++++++++++++++++++++++ packages/core/src/tools/task-list.ts | 9 ++++--- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/packages/core/src/tools/task-list.test.ts b/packages/core/src/tools/task-list.test.ts index 49ffd01f07e..a5b5965f9c5 100644 --- a/packages/core/src/tools/task-list.test.ts +++ b/packages/core/src/tools/task-list.test.ts @@ -130,6 +130,36 @@ describe('TaskListTool', () => { expect(result.llmContent).toContain('Legacy'); }); + it('treats a blank owner filter as omitted', async () => { + const t = await createTask(TEAM, { + subject: 'Owned', + description: 'desc', + }); + await updateTask(TEAM, t.id, { owner: 'alice' }); + + const invocation = tool.build({ owner: ' ' }); + const result = await invocation.execute(new AbortController().signal); + expect(result.llmContent).toContain('Owned'); + expect(result.llmContent).not.toContain('No tasks found'); + }); + + it('treats a blank blockedBy filter as omitted', async () => { + const dependency = await createTask(TEAM, { + subject: 'Dependency', + description: 'desc', + }); + const blocked = await createTask(TEAM, { + subject: 'Blocked', + description: 'desc', + }); + await updateTask(TEAM, blocked.id, { addBlockedBy: [dependency.id] }); + + const invocation = tool.build({ blockedBy: '' }); + const result = await invocation.execute(new AbortController().signal); + expect(result.llmContent).toContain('Blocked'); + expect(result.llmContent).not.toContain('No tasks found'); + }); + it('rejects owner filters that sanitize to empty', async () => { const invocation = tool.build({ owner: '!!!' }); const result = await invocation.execute(new AbortController().signal); diff --git a/packages/core/src/tools/task-list.ts b/packages/core/src/tools/task-list.ts index 2d339772cc0..487458de544 100644 --- a/packages/core/src/tools/task-list.ts +++ b/packages/core/src/tools/task-list.ts @@ -66,9 +66,12 @@ class TaskListInvocation extends BaseToolInvocation< }; } + const ownerParam = this.params.owner?.trim() || undefined; + const blockedByParam = this.params.blockedBy?.trim() || undefined; + let ownerFilter: string | undefined; - if (this.params.owner !== undefined) { - ownerFilter = sanitizeName(this.params.owner); + if (ownerParam !== undefined) { + ownerFilter = sanitizeName(ownerParam); if (!ownerFilter) { const msg = 'Cannot filter by owner: owner must include at least one ' + @@ -84,7 +87,7 @@ class TaskListInvocation extends BaseToolInvocation< const tasks = await listTasks(teamName, { status: this.params.status, owner: ownerFilter, - blockedBy: this.params.blockedBy, + blockedBy: blockedByParam, }); if (tasks.length === 0) {