test(e2e): expect embeddings API to reject empty string input - #723
test(e2e): expect embeddings API to reject empty string input#723christineschen wants to merge 1 commit into
Conversation
Original prompt from christine.chen
|
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
There was a problem hiding this comment.
Perry's Review
Verdict: 💬 Comments / questions
Risk: 🟢 Low
Details
Clean test-only fix for a red CI test. After openrouter-web#30855 tightened the embeddings request schema to reject empty input with a 400, the e2e test that asserted input: '' succeeds was failing. This PR flips it to assert the new contract instead.
Correctness:
- The SDK's
Embeddings.generate()callsunwrapAsync(), which throws theResulterror on a non-OK status. The 400 response is mapped toBadRequestResponseErrorviaM.jsonErr(400, ...), so.rejects.toThrow(BadRequestResponseError)correctly catches it. - Import path follows the repo's
.js-extension ESM convention.
CI: The validate check passes. All 5 e2e tests pass (was 4/5).
Note: I would have approved this, but the maintainer app isn't authorized on OpenRouterTeam, so this is a COMMENT verdict. LGTM from a review standpoint — safe to merge with a human approval.
No findings.
…716) ## Summary The OpenAPI tags are already `BYOK` / `TTS` / `STT`, but Speakeasy re-cases single all-caps tokens, so generated symbols came out as `Byok`, `Tts`, `Stt`. The fix is generator config, not a hand edit: `customCasings` declares terms whose PascalCase form must stay all-caps. ```diff typescript: version: 1.2.0 + customCasings: + byok: + initialism: true + stt: + initialism: true + tts: + initialism: true ``` Regenerated with the pinned `speakeasyVersion` (1.787.0), which renames the sub-SDK classes (`class Byok` → `class BYOK`, `Tts` → `TTS`, `Stt` → `STT`, modules stay `src/sdk/byok.ts` etc.) and the `ApiType` enum keys. Unchanged: accessors (`openrouter.byok`, `.tts`, `.stt`), camelCase properties (`isByok`, `includeByokInLimit`), and every wire value/JSON name — only `pascal` casing feeds generated symbol names. ### Breaking for source consumers `ApiType` is re-exported from `@openrouter/sdk/models`, and **two** of its keys change (the values don't): ```diff export const ApiType = { - Tts: "tts", - Stt: "stt", + TTS: "tts", + STT: "stt", } as const; ``` So `ApiType.Tts` / `ApiType.Stt` and direct imports of the `Byok`/`Tts`/`Stt` classes stop compiling; `ApiType.TTS` / `ApiType.STT` replace them. Worth calling out in release notes. ### Also included `tests/e2e/embeddings.test.ts` asserted that `input: ''` succeeds, but openrouter-web#30855 tightened the embeddings schema to `z.string().min(1)`, so the live API now returns 400 and the `validate` job failed on every typescript-sdk PR (including Speakeasy's own regen branches). The test now asserts the current contract: ```ts it('should reject an empty string input', async () => { await expect(client.embeddings.generate({ requestBody: { input: '', model: 'openai/text-embedding-3-small' } })) .rejects.toThrow(BadRequestResponseError); }); ``` This supersedes #723. Scope note: `Api` → `API` was deliberately left alone (`APIKeys` already renders correctly since the tag is `API Keys`; renaming `ApiType` and friends would be a much wider change). Matching python-sdk PR (merged): OpenRouterTeam/python-sdk#561 · go-sdk (merged): OpenRouterTeam/go-sdk#480 Version is hand-set to **1.2.0** in `gen.yaml` (Speakeasy honours a custom version: `versioning: custom SDK version detected`), since the generator would otherwise have shipped this source break as a patch. Local `pnpm run typecheck`, `eslint`, and the unit suite pass. BREAKING CHANGE: `ApiType.Tts` and `ApiType.Stt` are renamed to `ApiType.TTS` and `ApiType.STT` (enum values `"tts"`/`"stt"` unchanged), and the deep-importable sub-SDK classes `Byok`/`Tts`/`Stt` are renamed to `BYOK`/`TTS`/`STT`. Runtime behaviour, JSON field names, and the `openrouter.byok`/`.tts`/`.stt` accessors are unchanged. Link to Devin session: https://openrouter.devinenterprise.com/sessions/236b5466ec42476c8645101ef5bcd17f Requested by: @christineschen --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Summary
validatehas been red on every PR (mine, and Speakeasy's autogen branches) since openrouter-web#30855 — "fix(embeddings): validate non-empty input…" — tightened the embeddings request schema on Jul 27:Prod now answers
input: ''with400 too_small: expected string to have >=1 characters, so the e2e test that asserted empty input succeeds throws instead. This flips the test to assert the new (intended) contract:No SDK/source change —
tests/e2e/embeddings.test.tsonly. Verified against the live API:vitest run tests/e2e/embeddings.test.ts→ 5/5 pass (was 4/5).Link to Devin session: https://openrouter.devinenterprise.com/sessions/236b5466ec42476c8645101ef5bcd17f
Requested by: @christineschen