fix(web): don't fetch plugin-auth routes for non-builtin tool providers (#39169)#39206
Open
Taranum01 wants to merge 1 commit into
Open
Conversation
…rs (langgenius#39169) The Agents configure page (/agents/<id>/configure) was firing a `GET /workspaces/current/tool-provider/builtin/<id>/credential/...` request for every tool in the agent, including custom (api) tool providers. Custom API tools have their credentials stored on the `tool_api_providers` row — they do not go through the plugin daemon — so passing an api-provider row id to the builtin route raised `PluginNotFoundError` in the plugin daemon and surfaced as a 500 toast on every configure page load. Two fixes: 1. `useGetApi` now short-circuits to an empty URL set when called with an explicitly-set non-builtin `providerType`. All plugin-auth `useQuery` hooks key off `enabled: !!url`, so handing back empty strings opts the call out cleanly. Legacy callers that pre-date the `providerType` field (i.e. pass `undefined`) keep their original builtin URL behavior. 2. `CredentialStatus` short-circuits to `null` for non-builtin `providerType` in both the unauthorized and authorized branches, mirroring the existing `canSwitchCredential` gate. This avoids rendering a "Not authorized" button that has no meaningful action for custom (api) tools and prevents the matching `AuthorizedInNode` flow from firing either. Regression tests: - Extended `use-get-api.spec.ts` with a `providerType gating (langgenius#39169)` block pinning the contract for builtin, api, mcp, and undefined `providerType`. - New `provider-tool/__tests__/item.spec.tsx` covers the render-level guard: `usePluginAuth` is never called for an api-type tool (unauthorized or authorized), but is still called for a builtin one. Refs langgenius#39169 Signed-off-by: Taranum Wasu <taranumwasu@Taranums-MacBook-Pro.local> Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #39169 — Agents configure page (
/agents/<id>/configure) was firingGET /workspaces/current/tool-provider/builtin/<id>/credential/...for every tool in theagent, including custom (api) tool providers. Because custom (api) providers have their
credentials stored on the
tool_api_providersrow and do not go through the plugin daemon,passing an api-provider row id to the builtin route raised
PluginNotFoundErrorand surfacedas a 500 toast on every configure page load.
Repro (per the issue)
header auth.
/agents/<agent_id>/configure— the configure page requestsGET /console/api/workspaces/current/tool-provider/builtin/<api-row-uuid>/credential/schema/api-key→ 500 with
PluginNotFoundError. Chat and runtime are unaffected; this is a console-onlycosmetic regression that also adds a permanent warning badge on the Configuration menu item.
Fix
Two layers of defense:
useGetApishort-circuits to an empty URL set for non-builtinproviderType.All plugin-auth
useQueryhooks key offenabled: !!url, so handing back empty stringsopts the call out cleanly. Legacy callers that pre-date the
providerTypefield (passundefined) keep their original builtin URL behavior — no risk of regressing unrelatedcall sites.
CredentialStatusshort-circuits tonullfor non-builtinproviderTypein both theunauthorized and authorized branches, mirroring the existing
canSwitchCredentialgate.This avoids rendering a "Not authorized" button that has no meaningful action for custom
(api) tools and prevents the matching
AuthorizedInNodeflow from firing either.The
useGetApichange is the minimal defense-in-depth: if any other call site ever forgetsto gate on
providerType, the underlying hook will still hand back empty URLs and theuseQuerywill stay disabled.Tests
use-get-api.spec.tswith aproviderType gating (#39169)block pinning thecontract for builtin, api, mcp, and undefined
providerType.provider-tool/__tests__/item.spec.tsxcovers the render-level guard:usePluginAuthis never called for an api-type tool (unauthorized or authorized), but is still called for
a builtin one.
All 4
useGetApi+AgentProviderToolItemtests + the 12 pre-existingtools/__tests__/index.spec.tsxtests pass.tscandtsslintare clean on the changedfiles (5875 checks). The pre-commit hook ran and passed.
Files
Refs #39169
Made with Cursor