feat: add Instagram connector support#397
Conversation
- Add "instagram" to SUPPORTED_TOOLKITS and ALLOWED_ARTIST_CONNECTORS - Add COMPOSIO_INSTAGRAM_AUTH_CONFIG_ID to authConfigs - Fix bug: move authConfigs construction above both return paths so custom OAuth configs apply regardless of account_id presence Co-Authored-By: Paperclip <noreply@paperclip.ing> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughInstagram toolkit support has been added to the Composio connector system across three related modules. Configuration additions extend the allowed artist connectors list to include Instagram. OAuth configuration logic in authorization handling was refactored to reduce duplication. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 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 docstrings
🧪 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.
No issues found across 3 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Requires human review: Modifies authorization logic and return shapes in validateAuthorizeConnectorRequest.ts; security-related changes and new feature integrations require human review.
Architecture diagram
sequenceDiagram
participant Client as Artist UI
participant API as Connector Service
participant Env as Environment (Env Vars)
participant DB as Database (Access Control)
Note over Client,DB: Discovery Flow
Client->>API: GET /api/connectors
API->>API: Filter SUPPORTED_TOOLKITS
Note right of API: NEW: includes "instagram"
API-->>Client: Return allowed connectors list
Note over Client,DB: Authorization Flow (POST /api/connectors/authorize)
Client->>API: Request authorization (connector, account_id?)
Note over API,Env: NEW: Custom OAuth Config Resolution
alt connector is "instagram"
API->>Env: Read COMPOSIO_INSTAGRAM_AUTH_CONFIG_ID
Env-->>API: Config ID
else connector is "tiktok"
API->>Env: Read COMPOSIO_TIKTOK_AUTH_CONFIG_ID
Env-->>API: Config ID
end
Note over API: CHANGED: authConfigs built before account check
alt account_id provided
API->>DB: checkAccountAccess(session_user, target_account)
alt Authorized
DB-->>API: Access Granted
API-->>Client: Return { account_id, connector, authConfigs }
else Unauthorized
DB-->>API: Access Denied
API-->>Client: 403 Forbidden
end
else no account_id provided
Note right of API: CHANGED: Now returns authConfigs in this branch too
API-->>Client: Return { session_accountId, connector, authConfigs }
end
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
lib/composio/connectors/validateAuthorizeConnectorRequest.ts (1)
53-62: Consider replacing per-connectorifblocks with a mapping helper.This branch pattern will keep expanding as new connectors are added. A small resolver utility would reduce duplication and help keep this validator slimmer.
♻️ Proposed refactor
+const CONNECTOR_AUTH_CONFIG_ENV: Record<string, string | undefined> = { + tiktok: process.env.COMPOSIO_TIKTOK_AUTH_CONFIG_ID, + instagram: process.env.COMPOSIO_INSTAGRAM_AUTH_CONFIG_ID, +}; + +function resolveConnectorAuthConfigs( + connector: string, +): Record<string, string> | undefined { + const authConfigId = CONNECTOR_AUTH_CONFIG_ENV[connector]; + return authConfigId ? { [connector]: authConfigId } : undefined; +} + export async function validateAuthorizeConnectorRequest( request: NextRequest, ): Promise<NextResponse | AuthorizeConnectorParams> { @@ - // Build auth configs for custom OAuth - const authConfigs: Record<string, string> = {}; - if (connector === "tiktok" && process.env.COMPOSIO_TIKTOK_AUTH_CONFIG_ID) { - authConfigs.tiktok = process.env.COMPOSIO_TIKTOK_AUTH_CONFIG_ID; - } - if (connector === "instagram" && process.env.COMPOSIO_INSTAGRAM_AUTH_CONFIG_ID) { - authConfigs.instagram = process.env.COMPOSIO_INSTAGRAM_AUTH_CONFIG_ID; - } - const resolvedAuthConfigs = Object.keys(authConfigs).length > 0 ? authConfigs : undefined; + const resolvedAuthConfigs = resolveConnectorAuthConfigs(connector);As per coding guidelines:
lib/**/*.ts: “DRY: Consolidate similar logic into shared utilities” and “Keep functions under 50 lines”.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/composio/connectors/validateAuthorizeConnectorRequest.ts` around lines 53 - 62, The per-connector if blocks building authConfigs should be replaced by a small resolver: create a map (e.g. AUTH_CONFIG_ENV_MAP) from connector key to the corresponding env var name (or a helper function getAuthConfigId(connector)) and use that to look up process.env once, adding authConfigs[connector] only when a value exists; then set resolvedAuthConfigs as before. Move the map/helper into a shared util (or the same module if private) to keep validateAuthorizeConnectorRequest.ts slim and follow the DRY rule, referencing the existing variables connector, authConfigs and resolvedAuthConfigs in your changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@lib/composio/connectors/validateAuthorizeConnectorRequest.ts`:
- Around line 53-62: The per-connector if blocks building authConfigs should be
replaced by a small resolver: create a map (e.g. AUTH_CONFIG_ENV_MAP) from
connector key to the corresponding env var name (or a helper function
getAuthConfigId(connector)) and use that to look up process.env once, adding
authConfigs[connector] only when a value exists; then set resolvedAuthConfigs as
before. Move the map/helper into a shared util (or the same module if private)
to keep validateAuthorizeConnectorRequest.ts slim and follow the DRY rule,
referencing the existing variables connector, authConfigs and
resolvedAuthConfigs in your changes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 979a00e0-5113-4527-a7db-d10dc5ace2a1
⛔ Files ignored due to path filters (2)
lib/composio/connectors/__tests__/getConnectors.test.tsis excluded by!**/*.test.*,!**/__tests__/**and included bylib/**lib/composio/connectors/__tests__/isAllowedArtistConnector.test.tsis excluded by!**/*.test.*,!**/__tests__/**and included bylib/**
📒 Files selected for processing (3)
lib/composio/connectors/getConnectors.tslib/composio/connectors/isAllowedArtistConnector.tslib/composio/connectors/validateAuthorizeConnectorRequest.ts
Manual Testing Results (Preview Deployment)Preview URL: GET /api/connectors
POST /api/connectors (Instagram)
POST /api/connectors (TikTok regression)
|
Summary
"instagram"toSUPPORTED_TOOLKITSandALLOWED_ARTIST_CONNECTORSCOMPOSIO_INSTAGRAM_AUTH_CONFIG_IDauth config for Instagram OAuthaccount_idpresenceTest plan
COMPOSIO_INSTAGRAM_AUTH_CONFIG_IDin envGET /api/connectorsreturns Instagram in artist connector listPOST /api/connectors/authorizewithconnector: "instagram"includes auth config🤖 Generated with Claude Code
Summary by cubic
Add an artist-level Instagram connector with custom OAuth, and apply
authConfigswith or withoutaccount_id(REC-49).New Features
SUPPORTED_TOOLKITSandALLOWED_ARTIST_CONNECTORS.COMPOSIO_INSTAGRAM_AUTH_CONFIG_ID.Bug Fixes
authConfigsbefore all return paths so custom OAuth applies regardless ofaccount_id; updated tests to include Instagram.Written for commit f365475. Summary will update on new commits.
Summary by CodeRabbit
New Features
Improvements