fix: pass authConfigs in getConnectors for custom OAuth connections#399
Conversation
… connections Connections created with custom auth configs (TikTok, Instagram) were invisible to getConnectors because it created sessions without matching authConfigs. Composio scopes connection lookups by auth config. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 14 minutes and 23 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdded an internal Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 1✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
1 issue found across 2 files
Confidence score: 4/5
- This PR is safe to merge with minimal risk: the only concern is test hygiene in
lib/composio/connectors/__tests__/getConnectors.test.ts, not production runtime behavior. - The cleanup currently uses unconditional
deleteonprocess.env, which can leak or erase global environment state and cause flaky cross-test interactions if the original values are not restored. - Pay close attention to
lib/composio/connectors/__tests__/getConnectors.test.ts- restoreprocess.envviatry/finallyto preserve prior values and avoid test-state pollution.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="lib/composio/connectors/__tests__/getConnectors.test.ts">
<violation number="1" location="lib/composio/connectors/__tests__/getConnectors.test.ts:77">
P2: Restore `process.env` values with `try/finally` instead of unconditional `delete`; the current cleanup can leak or erase global env state across tests.</violation>
</file>
Architecture diagram
sequenceDiagram
participant Caller as API Route / Caller
participant GC as getConnectors()
participant Env as Process Env
participant SDK as Composio Client
participant Remote as Composio API (External)
Caller->>GC: getConnectors(accountId)
rect rgb(240, 240, 240)
Note over GC,Env: NEW: Map custom OAuth credentials
GC->>Env: get COMPOSIO_TIKTOK_AUTH_CONFIG_ID
GC->>Env: get COMPOSIO_INSTAGRAM_AUTH_CONFIG_ID
Env-->>GC: authConfigs map
end
GC->>SDK: CHANGED: composio.create(accountId, { toolkits, authConfigs })
SDK->>Remote: POST /sessions (initiate session)
Note over Remote: Session is now scoped to specific<br/>TikTok/Instagram Auth Config IDs
alt Successful session creation
Remote-->>SDK: session object
SDK->>Remote: GET /toolkits (fetch connection status)
Note over Remote: Filtered by provided authConfigs
Remote-->>GC: toolkits[] (with isConnected status)
GC-->>Caller: Connector list
else API Error / Timeout
Remote-->>GC: Error
GC-->>Caller: Throw error
end
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
| * Must match the configs used during authorization so Composio | ||
| * can find connections created with custom OAuth credentials. | ||
| */ | ||
| function buildAuthConfigs(): Record<string, string> | undefined { |
There was a problem hiding this comment.
SRP - new lib file for buildAuthConfigs.
- actual: function name and file name are different.
- required: new file with the same name as the function.
- SRP: moved buildAuthConfigs to lib/composio/connectors/buildAuthConfigs.ts - Fixed test env var cleanup with try/finally to prevent leaking state Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Preview Deployment Testing ResultsPreview URL: GET /api/connectors?account_id=9105f630-8e9f-4908-a2c4-3f68a6454c78
Before fix (production)All connectors returned Root cause
|
Summary
getConnectorsbecause it created Composio sessions without matchingauthConfigsbuildAuthConfigs()helper that readsCOMPOSIO_TIKTOK_AUTH_CONFIG_IDandCOMPOSIO_INSTAGRAM_AUTH_CONFIG_IDfrom env varsTest plan
getConnectorsdid NOT passauthConfigsGET /api/connectors?account_id=9105f630-8e9f-4908-a2c4-3f68a6454c78returnsisConnected: truefor TikTok/Instagram🤖 Generated with Claude Code
Summary by cubic
Fixes
getConnectorsso TikTok and Instagram connections authorized with custom OAuth are returned. We now pass matchingauthConfigsfrom env vars when creating the Composio session.Bug Fixes
authConfigsto the Composio session ingetConnectors.buildAuthConfigs()module; readsCOMPOSIO_TIKTOK_AUTH_CONFIG_IDandCOMPOSIO_INSTAGRAM_AUTH_CONFIG_ID.Migration
Written for commit f81a7f3. Summary will update on new commits.
Summary by CodeRabbit