Repository navigation
fix(perplexity-web): reject an unmapped model name locally - #17822
diegosouzapw merged 2 commits into
Conversation
A model name in neither map was forwarded upstream as a raw preference. Reject it with a 404 instead, so a typo never leaves this process. Signed-off-by: Minxi Hou <houminxi@gmail.com>
|
Thanks @HouMinXi, and thanks for splitting this out of #17317 the way we asked. This is a clean, well-scoped change. A typo'd model name no longer leaves the process as a raw model_preference, and the 404 model_not_found return keeps the same {response, url, headers, transformedBody} shape as the neighbouring early returns, so the web-cookie sweep stays happy. I checked a few things on your head (8e77008): all 11 models in the perplexity-web registry are in MODEL_MAP, so valid aliases are unaffected. Your new test is red when I revert only the source hunk (the 404 assertion fails) and green with it. The "mapped model still reaches the counter" guard is a nice touch, because it stops a counter stuck at zero from passing the test. perplexity-web, model-mappings, cookie-rotation and upstream-status all pass on your branch, and ESLint is clean. Three small things we will fix in place on your branch so your commit and credit stay as they are:
One thing for you, when you get to #17317: please make sure it doesn't carry a copy of this hunk. If it registers a new Perplexity model id, for example a deep-research one, that id needs a MODEL_MAP entry too, because it would now get a 404 here. Your test uses pplx-deep-research as the unmapped example, so this one is easy to trip over. Last note: removing the raw-preference passthrough is a behaviour change, so the maintainer has the final call on it. I found nothing in the tests or docs that treated it as a supported feature. |
…, add changelog fragment (cheaper-inference#17822)
d2e0d83
into
cheaper-inference:release/v3.8.53
Conflict: - open-sse/executors/perplexity-web.ts (imports only): kept release's multi-line error.ts import with buildErrorBody, which the unmapped-model 404 from cheaper-inference#17822 needs, and kept this branch's nextAuthCookie import without buildSessionCookieHeader, which moved into buildPplxHeaders in perplexity-web/protocol.ts. The executor body merged cleanly: the cheaper-inference#17822 404 branch and this branch's buildPplxHeaders call are both present, and buildPplxHeaders reads PPLX_USER_AGENT, so it sends the Firefox 151 UA from cheaper-inference#17838.
Summary
MODEL_MAPnorTHINKING_MAPwas forwarded upstream as a raw preference. This rejects it locally with a 404 andmodel_not_found, so a typo never leaves the process.Test plan
pplx-sonar) still reaches the counter.url,headersandtransformedBody.