Skip to content

Commit fa9ebce

Browse files
authored
fix(server/rest): handle undefined historyLength to return full task history (#527)
# Description ## What REST `getTask` no longer defaults `historyLength: 0`. The field is omitted when the client doesn't provide the query parameter, matching JSON-RPC and gRPC bindings. ## Why Spec §3.2.4: "Unset/undefined: No limit imposed; server returns its default amount of history. 0: No history should be returned." JS REST diverged by defaulting to 0, so `GET /tasks/{id}` without `?historyLength=N` returned an empty history. Closes #535
1 parent a3dd703 commit fa9ebce

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/server/transports/rest/rest_transport_handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ export class RestTransportHandler {
213213
historyLength?: unknown,
214214
tenant?: string
215215
): Promise<Task> {
216-
const params: GetTaskRequest = { id: taskId, historyLength: 0, tenant: tenant || '' };
216+
const params: GetTaskRequest = { id: taskId, tenant: tenant || '' };
217217
if (historyLength !== undefined) {
218218
params.historyLength = this.parseHistoryLength(historyLength);
219219
}

test/server/express/rest_handler.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ describe('restHandler', () => {
300300
// Status state is enum string
301301
assert.deepEqual(response.body.status.state, 'TASK_STATE_COMPLETED');
302302
expect(mockRequestHandler.getTask as Mock).toHaveBeenCalledWith(
303-
{ id: 'task-1', tenant: '', historyLength: 0 },
303+
{ id: 'task-1', tenant: '' },
304304
expect.anything()
305305
);
306306
});

test/server/rest_transport_handler.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ describe('RestTransportHandler', () => {
248248

249249
expect(result).to.deep.equal(testTask);
250250
expect(mockRequestHandler.getTask as Mock).toHaveBeenCalledWith(
251-
{ id: 'task-1', historyLength: 0, tenant: '' },
251+
{ id: 'task-1', tenant: '' },
252252
mockContext
253253
);
254254
});

0 commit comments

Comments
 (0)