Skip to content

fix(perplexity-web): reject an unmapped model name locally - #17822

Merged
diegosouzapw merged 2 commits into
cheaper-inference:release/v3.8.53from
HouMinXi:fix/pplx-unmapped-model
Oct 25, 2026
Merged

diegosouzapw merged 2 commits into
cheaper-inference:release/v3.8.53from
HouMinXi:fix/pplx-unmapped-model

Conversation

@HouMinXi

Copy link
Copy Markdown
Contributor

Summary

  • A model name that is in neither MODEL_MAP nor THINKING_MAP was forwarded upstream as a raw preference. This rejects it locally with a 404 and model_not_found, so a typo never leaves the process.
  • Split out of feat(mcp): add a deep research tool that is off by default #17317 at the reviewer's request, because it changes existing chat behaviour and deserves its own review.

Test plan

  • An unmapped model returns 404 and the fetch counter stays at 0.
  • A mapped model (pplx-sonar) still reaches the counter.
  • The web cookie sweep passes, since the 404 result carries url, headers and transformedBody.

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>
@diegosouzapw

Copy link
Copy Markdown
Collaborator

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:

  1. Prettier formatting on tests/unit/perplexity-web-unmapped-model.test.ts (the dynamic import destructure on lines 6-8).
  2. A changelog fragment, changelog.d/fixes/17822-perplexity-web-reject-unmapped-model.md.
  3. Building the 404 body with buildErrorBody() from open-sse/utils/error.ts, as claude-web does, instead of hand-written JSON, so the message goes through our error sanitization.

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.

@diegosouzapw
diegosouzapw merged commit d2e0d83 into cheaper-inference:release/v3.8.53 Oct 25, 2026
53 of 57 checks passed
HouMinXi added a commit to HouMinXi/OmniRoute that referenced this pull request Oct 26, 2026
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.
@HouMinXi
HouMinXi deleted the fix/pplx-unmapped-model branch October 28, 2026 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants