{"record":{"id":"2c9ccefe6ffe1617","repo":"mastra-ai/mastra","slug":"connection-connectionid-not-found-for-provider","errorCode":null,"errorMessage":"Connection ${connectionId} not found for provider ${providerId}","messagePattern":"Connection (.+?) not found for provider (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"packages/server/src/server/handlers/tool-providers.ts","lineNumber":693,"sourceCode":"  handler: async ({ mastra, providerId, connectionId, label, requestContext }) => {\n    try {\n      const editor = requireEditor(mastra.getEditor());\n      const provider = await resolveProvider(editor, providerId);\n      const callerAuthorId = resolveOwnerId(requestContext, mastra.getLogger());\n      const isAdmin = requestContext ? hasAdminBypass(requestContext, TOOL_PROVIDERS_RESOURCE) : false;\n\n      const storage = mastra.getStorage();\n      const store = await storage?.getStore('toolProviderConnections');\n      if (!store) {\n        throw new HTTPException(500, {\n          message: 'Tool provider connections storage is not configured',\n        });\n      }\n\n      const rows = await store.listConnectionsByAuthor({ providerId: provider.info.id });\n      const match = rows.find(r => r.connectionId === connectionId);\n      if (!match) {\n        throw new HTTPException(404, {\n          message: `Connection ${connectionId} not found for provider ${providerId}`,\n        });\n      }\n\n      const isShared = match.scope === 'shared';\n      if (!isShared && match.authorId !== callerAuthorId && !isAdmin) {\n        throw new HTTPException(403, {\n          message: 'You do not have permission to update this connection',\n        });\n      }\n\n      // Normalize: empty string and explicit null both clear the label.\n      const nextLabel: string | null = typeof label === 'string' && label.trim().length > 0 ? label.trim() : null;\n\n      await store.upsertConnection({\n        authorId: match.authorId,\n        providerId: provider.info.id,\n        toolkit: match.toolkit,","sourceCodeStart":675,"sourceCodeEnd":711,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/tool-providers.ts#L675-L711","documentation":"A 404 thrown when no connection row with the given connectionId exists for the provider, after listing connections by the caller's author. The server looks up rows scoped to the provider and the caller's authorship; a mismatched or nonexistent ID yields this error.","triggerScenarios":"GET/PUT/DELETE on a connection whose connectionId was never created, belongs to a different providerId, or is scoped to another author so it isn't in listConnectionsByAuthor results for the caller.","commonSituations":"Typo'd or stale connectionId from a previous environment; connection created under a different author (personal scope) so the caller's listing omits it; using a connectionId from a different provider.","solutions":["Verify connectionId and providerId are correct; list connections for the provider first.","If the connection belongs to another author, act as an admin or use the shared-scope connection's ID.","Recreate the connection if it was deleted, and use the new connectionId."],"exampleFix":"// before\nawait api.get(`/api/tool-providers/github/connections/conn_123`);\n// after\nconst { connections } = await api.get(`/api/tool-providers/github/connections`);\nconst target = connections.find(c => c.label === 'my-github');\nawait api.get(`/api/tool-providers/github/connections/${target.connectionId}`);","handlingStrategy":"validation","validationCode":"const list = await api.get(`/api/tool-providers/${providerId}/connections`);\nif (!list.connections.some(c => c.connectionId === connectionId)) {\n  throw new Error(`Unknown connectionId ${connectionId} for provider ${providerId}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await api.get(`/api/tool-providers/${p}/connections/${id}`);\n} catch (e) {\n  if (e.status === 404) {\n    const { connections } = await api.get(`/api/tool-providers/${p}/connections`);\n    // refresh local cache of valid connection IDs\n  } else throw e;\n}","preventionTips":["Fetch and cache connection IDs from the list endpoint instead of hardcoding.","Verify scope/author of connections you reference across users.","Refresh stored connection IDs after deletes/recreations."],"tags":["http-404","tool-providers","not-found","api"],"backgroundTag":"resource-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}