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:
+1
-1
@@ -79,7 +79,7 @@ public sealed class BatchMcpTools
|
|||||||
|
|
||||||
private static readonly string[] KnownDetailFields =
|
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",
|
"startedAt", "finishedAt", "isMyDay", "sortOrder", "roadblockCount", "roadblockText",
|
||||||
"failureReason",
|
"failureReason",
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -324,6 +324,26 @@ public sealed class BatchMcpToolsTests : IDisposable
|
|||||||
Assert.Contains("notAField", ex.Message);
|
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]
|
[Fact]
|
||||||
public async Task BatchGetTasks_RoadblockTextField_ExtractsTailOfResult_WithoutFullResult()
|
public async Task BatchGetTasks_RoadblockTextField_ExtractsTailOfResult_WithoutFullResult()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user