websearch: tavily provider returns 403 (key rejected via Bearer auth)

Aperta Adatta ai principianti
#65,880 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
80/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
api

Direzione di ricerca

Inizia da packages/core/src/plugin/websearch/tavily.ts, dove il provider attualmente invia Authorization: Bearer <key>. Confrontalo con la richiesta documentata di Tavily con api_key nel corpo e riproduci il 403 usando la stessa chiave configurata. La correzione dovrebbe passare al metodo di autenticazione accettato o ricadere su di esso e mostrare un errore più chiaro quando l'autenticazione fallisce; fatto significa che una ricerca web riesce con una chiave tvly-dev-.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area/core platform/windows type/bug version/v2

Summary

The built-in web search with provider tavily fails with HTTP 403 on every
search. The same API key works when sent as api_key in the request body, but
is rejected when sent as Authorization: Bearer <key> — which is how the
Tavily websearch provider sends it.

Environment

  • opencode version: 2.4.1 (desktop app)
  • OS: Windows 10.0.19045.6456 (win32 x64)
  • websearch provider: tavily
  • Tavily key: tvly-dev-… (dev/free tier)

Reproduction

  1. Configure websearch.provider = "tavily" and set TAVILY_API_KEY.
  2. Ask the model to search the web.
  3. Observe: Web search request failed (HTTP 403).

Expected Behavior

Web search returns results using the configured Tavily key.

Actual Behavior

Every search returns HTTP 403. Direct API tests with the same key (from the
same machine/IP) show:

  • POST https://api.tavily.com/search with {"api_key": "<key>", ...}
    -> 200 OK
  • POST https://api.tavily.com/search with header
    Authorization: Bearer <key> -> 403 Forbidden (HTML response)

The provider sends the key as a Bearer token
(packages/core/src/plugin/websearch/tavily.ts):

...(credential?.type === "key"
  ? { Authorization: `Bearer ${credential.key}` }
  : { "X-Tavily-Access-Mode": "keyless" }),

So the 403 is Tavily rejecting Bearer auth for this key — not a network/VPN
issue and not an invalid key (the same key returns 200 via the body method).

Additional Context

  • On another machine where only the Tavily MCP server is used (which sends the
    key differently), no such error occurs.
  • A tvly-dev- key may only support the legacy api_key-in-body
    authentication. If so, the provider could fall back to that method, or
    surface a clearer error than a bare 403.
Lingua principale
TypeScript
Stelle
228k
Fork
31k
Merge medio
3h 22m
PR unite (30g)
476

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di anomalyco/opencode

Tutte le issue di anomalyco/opencode

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.