fix(worker): batch_get_tasks accept "number" and "id" in fields filter

batch_get_tasks with fields: ["number", ...] was rejected with "Unknown
field(s)" even though every task DTO always carries id and number. Add
both to KnownDetailFields so they are accepted; BuildDetail already emits
them regardless of the fields filter.

Also add a test verifying fields: ["number", "title"] works and
description is properly excluded.
This commit is contained in:
mika kuns
2026-10-01 13:26:47 +02:00
parent c834f17c78
commit ef5dad2700
2 changed files with 21 additions and 1 deletions
+1 -1
View File
@@ -79,7 +79,7 @@ public sealed class BatchMcpTools
private static readonly string[] KnownDetailFields =
{
"listId", "title", "description", "status", "result", "createdBy", "createdAt",
"id", "number", "listId", "title", "description", "status", "result", "createdBy", "createdAt",
"startedAt", "finishedAt", "isMyDay", "sortOrder", "roadblockCount", "roadblockText",
"failureReason",
};
@@ -324,6 +324,26 @@ public sealed class BatchMcpToolsTests : IDisposable
Assert.Contains("notAField", ex.Message);
}
[Fact]
public async Task BatchGetTasks_NumberAndIdFields_AcceptedAndReturned()
{
var listId = await SeedListAsync();
var task = await SeedTaskAsync(listId);
task.Description = "full description not requested";
await _tasks.UpdateAsync(task);
var sut = BuildSut();
var results = await sut.BatchGetTasks(
new[] { task.Id }, includeDescription: true, fields: new[] { "number", "title" },
cancellationToken: CancellationToken.None);
var found = results.Single(r => r.Id == task.Id).TaskFull!;
Assert.Equal(task.Number, found.Number);
Assert.Equal(task.Id, found.Id);
Assert.Equal(task.Title, found.Title);
Assert.Null(found.Description); // Not requested
}
[Fact]
public async Task BatchGetTasks_RoadblockTextField_ExtractsTailOfResult_WithoutFullResult()
{