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

未关闭 适合新手
#65,880 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
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- 密钥可以成功进行 Web 搜索。

由索引模型根据 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 分钟
30 天内合并 PR
476

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

anomalyco/opencode 的其他 Issue

查看 anomalyco/opencode 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。