a2aproject / a2aproject/a2a-js

[Bug]: REST listTasks drops historyLength=0 and accepts NaN pageSize

オープン 初心者向け
#679 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
TypeScript
スター
613
フォーク
169
平均マージ
1日 6時間
マージ済み PR(30日)
21

説明

### What happened?

`RestTransportHandler.listTasks` builds params with truthy coercions:

```
historyLength: queryParams.historyLength ? Number(...) : undefined
pageSize: queryParams.pageSize ? Number(...) : undefined
```

Express query values are strings, so `historyLength=0` and `pageSize=0` become undefined. Spec and `DefaultRequestHandler._applyHistoryLengthSemantics` treat 0 as "omit history". `getTask` already keeps 0 via `parseHistoryLength`. The JS REST client sends `historyLength=0`, so a same-SDK listTasks call returns full history.

Non-numeric `pageSize=abc` becomes NaN. The handler only checks `pageSize < 1 || pageSize > 100`, and both comparisons are false for NaN, so the store does `tasks.slice(0, NaN)` and returns an empty page with HTTP 200.

Related: closed unmerged PR #625 diagnosed the REST Number() hole. Open PR #639 caps historyLength at 1000 but does not fix the truthy drop of 0 or NaN pageSize.

**Repro**
1. Persist a task with at least two history messages.
2. `GET /tasks?historyLength=0` with `A2A-Version: 1.0`.
Observed: full history. Expected: `history` is `[]`.
3. `GET /tasks?pageSize=abc`.
Observed: 200 with `tasks=[]`. Expected: 400 RequestMalformedError.

### Relevant log output

n/a.

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Look at RestTransportHandler.listTasks in the codebase, likely in a file like src/transport/rest.ts. The bug is in the truthy coercion for historyLength and pageSize. Start by understanding how query parameters are parsed and where Number() conversions happen. Check related PRs #625 and #639 for context. Write a test to reproduce the described behavior, then fix the coercion to handle 0 and NaN correctly. Ensure the fix aligns with the spec's handling of historyLength=0 and returns a 400 error for non-numeric pageSize.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, nodejs, typescript
領域
api, backend
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
活発
明瞭さ
明確に書かれている
初心者へのやさしさ
70/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。