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

オープン 初心者向け
#65,880 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
80/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
api

調査の方向性

packages/core/src/plugin/websearch/tavily.ts から始めてください。ここではプロバイダーが現在 Authorization: Bearer <key> を送信しています。Tavily のドキュメントにある api_key をボディに含めるリクエストと比較し、同じ設定済みのキーを使って 403 を再現してください。修正では、受け入れられる認証方式に切り替えるかフォールバックし、認証に失敗したときにより明確なエラーを表示する必要があります。完了とは、tvly-dev- キーでウェブ検索が成功することです。

索引モデルが issue の本文から書いたものです。

説明

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.
主要言語
TypeScript
スター
228k
フォーク
31k
平均マージ
3時間 22分
マージ済み PR(30日)
476

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

anomalyco/opencode のほかの issue

anomalyco/opencode の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。