You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 12a4315
Browse filesBrowse the repository at this point in the historyBrowse files
fix: reject unknown Anthropic model cursors and document auth changes (#551)
## Problem
Unknown `after_id` and `before_id` values returned successful empty
Anthropic model pages. Authentication docs missed the new native
error-body migration details. The CI drift rule also required the old
cursor behavior and rejected the corrected response.
## Why
SDK callers need an error for an invalid cursor. Apps reading the old
string `error.code` need to know that Anthropic omits it and
Gemini/Vertex return numeric `401`. CI must check the new response while
retaining its known missing-request-ID warning and the historical base
comparison.
## Fix
Reject unknown Anthropic cursors with HTTP 400, including with lifecycle
filters. Keep valid paging and empty filtered pages working. Update
README, changelog, provider docs, cursor tests and the drift grading
rule. Header enforcement stays opt-in.
The grading rule requires the exact status, error type, message and
single known warning. It accepts the old empty-page policy only for
cached base evidence. Regression tests mutate receipts, assertions and
diffs to verify the gate still rejects mismatches. A saved actual CI
receipt replay passes with 11 advisories and no blocks; this does not
claim full response-body parity or fresh authenticated calls.
Validation: format, lint, typecheck, all 428 test files (17,456 passed;
11 existing skips), build, package exports, all 14 unchanged API
reports, and actionlint with ShellCheck passed. The earlier free-RAM
test failure passed unchanged. Separate Node/Bun consumers passed 48
cursor checks each plus the original 38 each.
Stacked above #542 using GitHub's native stack #552. The provider
compatibility follow-up is #553, based on this PR. Merge only after
required checks pass, in stack order.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,8 +12,13 @@
12
12
13
13
- Responses API (HTTP, SSE, WebSocket): optional `phase` response override (`commentary` | `final_answer`) on assistant message output items; validated on load (#531)
14
14
15
+
### Changed
16
+
17
+
-**Authentication error compatibility:** configured inbound auth no longer returns the string `error.code: "invalid_api_key"` on Anthropic Messages/count and Gemini/Vertex Google HTTP paths. Anthropic omits `error.code`; check HTTP 401 or `error.type: "authentication_error"`. Google returns numeric `error.code: 401`; check HTTP 401 or `error.status: "UNAUTHENTICATED"`. Update clients and tests that read the old field. Shared `/v1/models` and WebSocket rejections keep their existing bodies.
18
+
15
19
### Fixed
16
20
21
+
- Anthropic model lists reject unknown `after_id` and `before_id` cursors with 400 `invalid_request_error`, including when a lifecycle filter would return an empty page. Valid cursors and OpenAI-style lists keep their existing paging behavior.
17
22
- Shared `/v1/models` paths select the Anthropic catalog when `anthropic-version` is present, or when `x-api-key` is present without `Authorization`. Non-Anthropic clients that use `x-api-key` alone also receive that catalog. Use `Authorization` without `anthropic-version` to retain the OpenAI format.
18
23
- Configured inbound authentication returns native 401 bodies on Anthropic Messages/count and Gemini/Vertex Google HTTP paths. Anthropic adds a `request-id` response header. Shared model paths and WebSocket rejections retain their existing bodies. Anthropic's upstream diagnostic message and body `request_id` differ. The observed Gemini gateway 403 differs from aimock's intentional inbound 401.
Use `Authorization: Bearer <key>`, `Authorization: Key <key>`, `x-api-key`, `x-goog-api-key`, `api-key`, or `xi-api-key`. Every supplied credential must resolve to one configured key; mismatches return `401` with an OpenAI-compatible authentication error. HTTP routes, control APIs, mounts, and WebSocket upgrades are protected. Genuine CORS preflights plus `GET /health`, `GET /ready`, and `GET /metrics` remain public. This is inbound test access control, distinct from `record.providerKeys`; when enabled, proxying strips test credentials and requires a configured static provider credential before egress.
261
+
Use `Authorization: Bearer <key>`, `Authorization: Key <key>`, `x-api-key`, `x-goog-api-key`, `api-key`, or `xi-api-key`. Every supplied credential must resolve to one configured key; mismatches return `401`. HTTP routes, control APIs, mounts, and WebSocket upgrades are protected. Genuine CORS preflights plus `GET /health`, `GET /ready`, and `GET /metrics` remain public. This is inbound test access control, distinct from `record.providerKeys`; when enabled, proxying strips test credentials and requires a configured static provider credential before egress.
262
+
263
+
**Auth error compatibility:** Anthropic Messages/count now omit the old `error.code: "invalid_api_key"`; check HTTP 401 or `error.type: "authentication_error"`. Gemini/Vertex Google HTTP paths replace that string with numeric `error.code: 401`; check HTTP 401 or `error.status: "UNAUTHENTICATED"`. Shared `/v1/models`, other HTTP paths, and WebSocket rejections keep their existing OpenAI-shaped error bodies. See the [Anthropic](docs/claude-messages/index.html#authentication-errors) and [Gemini](docs/gemini/index.html#authentication-errors) examples before updating client assertions.
0 commit comments