anthropics / anthropics/anthropic-sdk-php
List-type query params are serialised as types[0]= instead of types[]=, causing a 400
- 主要言語
- PHP
- スター
- 180
- フォーク
- 54
- 平均マージ
- 12時間 17分
- マージ済み PR(30日)
- 6
説明
Hi, I'm running into an issue with list-valued query params - they're serialised with indexed keys, which the API rejects. As far as I can tell this makes any endpoint taking a list query param unusable via the sdk.
**Repro** (v0.41.0):
```php
$client = new Anthropic\Client(apiKey: getenv('ANTHROPIC_API_KEY'));
$client->beta->sessions->events->list(
'sesn_XXXX',
types: ['session.usage'],
betas: ['managed-agents-2026-04-01'],
);
```
**Result:**
```
PHP Fatal error: Uncaught Anthropic\Core\Exceptions\BadRequestException: Anthropic Bad Request Exception
{
"status": 400,
"body": {
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "Unknown query parameter 'types[0]'. Valid parameters: created_at[gt], created_at[gte], created_at[lt], created_at[lte], limit, order, page, types[]."
},
"request_id": "req_011Cduwz9HqW8WLyFkJnT1EL"
}
} in vendor/anthropic-ai/sdk/src/Core/Exceptions/APIStatusException.php:67
Stack trace:
#0 src/Core/BaseClient.php(367): Anthropic\Core\Exceptions\APIStatusException::from(Object(Nyholm\Psr7\Request), Object(Nyholm\Psr7\Response))
#1 src/Core/BaseClient.php(93): Anthropic\Core\BaseClient->sendRequest(Object(Anthropic\RequestOptions), Object(Nyholm\Psr7\Request), NULL, 0, 0)
#2 src/Services/Beta/Sessions/EventsRawService.php(123): Anthropic\Core\BaseClient->request('GET', Array, Array, Array, NULL, NULL, ...)
#3 src/Services/Beta/Sessions/EventsService.php(123): Anthropic\Services\Beta\Sessions\EventsRawService->list('sesn_...', Array, NULL)
#4 repro.php(7): Anthropic\Services\Beta\Sessions\EventsService->list('sesn_...', NULL, NULL, NULL, NULL, NULL, NULL, NULL, Array, Array)
```
The SDK sends `types%5B0%5D=session.usage`; the API accepts `types%5B%5D=session.usage`.
**Cause:** `src/Core/Util.php:255` and `src/Core/RequestTransformer.php:146` use `http_build_query()`, which always emits indexed keys for lists and has no repeated-key mode. Affects all list-valued query params. Named sub-keys like `created_at[gt]` are fine.
**Fix:** serialise lists as repeated `key[]=` pairs.
コントリビューションガイド
評価
この issue はまだ評価されていません。