Skip to content

feat: enrich connectors response with social profile data#406

Open
recoup-coding-agent wants to merge 1 commit intotestfrom
feat/connectors-social-profile
Open

feat: enrich connectors response with social profile data#406
recoup-coding-agent wants to merge 1 commit intotestfrom
feat/connectors-social-profile

Conversation

@recoup-coding-agent
Copy link
Copy Markdown
Collaborator

@recoup-coding-agent recoup-coding-agent commented Apr 6, 2026

Summary

  • GET /api/connectors now returns avatar and username for connected Instagram/TikTok connectors
  • Social profile data matched from account_socials in Supabase using hostname-based URL matching

Changes

  • ConnectorInfo: added optional avatar and username fields
  • enrichConnectorsWithSocials: new function matching socials by hostname
  • getConnectorsHandler: calls enrichment after Composio fetch
  • Tests for enrichment logic

Test plan

  • GET /api/connectors?account_id=artist returns avatar/username for connected Instagram/TikTok
  • Unconnected connectors have no avatar/username
  • Google connectors unaffected
  • User-level connectors unaffected

Generated with Claude Code


Summary by cubic

GET /api/connectors now includes avatar and username for connected Instagram and TikTok connectors when account_id is provided, using Supabase social profiles. Other connectors and unconnected items are unchanged.

  • New Features
    • Socials are looked up from account_socials and matched by hostname (instagram.com, tiktok.com).
    • Added avatar and username to ConnectorInfo; new enrichConnectorsWithSocials; handler enriches after Composio fetch.
    • Tests cover matching, no-match, unconnected connectors, and subdomain hostname edge cases.

Written for commit ae33d59. Summary will update on new commits.

GET /api/connectors now returns avatar and username for connected
Instagram/TikTok connectors by looking up matching social profiles
from the artist's account_socials in Supabase.

- Add avatar/username to ConnectorInfo interface
- New enrichConnectorsWithSocials function with hostname-based matching
- Handler calls enrichment after fetching Composio connectors
- Tests for enrichment logic

Co-Authored-By: Paperclip <noreply@paperclip.ing>
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
recoup-api Ready Ready Preview Apr 6, 2026 11:37pm

Request Review

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 issues found across 4 files

Confidence score: 2/5

  • There is a high-confidence functional risk in lib/composio/connectors/enrichConnectorsWithSocials.ts: new URL(profileUrl) can throw for protocol-less normalized URLs, which can cause valid Instagram/TikTok matches to be missed.
  • lib/composio/connectors/getConnectorsHandler.ts currently risks turning /api/connectors into a 500 when enrichment fails, even if connector retrieval succeeded, which is user-facing reliability impact.
  • The typing issue in lib/composio/connectors/enrichConnectorsWithSocials.ts (any in social mapping) increases maintenance and correctness risk, especially alongside the parsing bug in the same flow.
  • Pay close attention to lib/composio/connectors/enrichConnectorsWithSocials.ts and lib/composio/connectors/getConnectorsHandler.ts - URL parsing and error-handling paths can cause missed social enrichment and endpoint failures.
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/enrichConnectorsWithSocials.ts">

<violation number="1" location="lib/composio/connectors/enrichConnectorsWithSocials.ts:23">
P1: `new URL(profileUrl)` fails for normalized profile URLs stored without protocol, causing social matching to miss valid Instagram/TikTok records.</violation>

<violation number="2" location="lib/composio/connectors/enrichConnectorsWithSocials.ts:48">
P1: Custom agent: **Enforce Clear Code Style and Maintainability Practices**

Rule 1 (strict TypeScript typing) is violated by using `any` in the social mapping; use the typed `social` field directly instead of bypassing type checks.</violation>
</file>

<file name="lib/composio/connectors/getConnectorsHandler.ts">

<violation number="1" location="lib/composio/connectors/getConnectorsHandler.ts:49">
P2: Handle enrichment failures gracefully so social-profile lookup errors don’t turn `/api/connectors` into a 500 when connector data was fetched successfully.</violation>
</file>
Architecture diagram
sequenceDiagram
    participant Client
    participant Handler as getConnectorsHandler
    participant Composio as getConnectors
    participant Enricher as enrichConnectorsWithSocials
    participant DB as Supabase (account_socials)

    Client->>Handler: GET /api/connectors?account_id={id}
    
    Handler->>Handler: validateGetConnectorsRequest()
    
    Handler->>Composio: getConnectors({ accountId })
    Note right of Composio: Fetch connection status for<br/>Google, TikTok, Instagram
    Composio-->>Handler: ConnectorInfo[] (slug, name, isConnected)
    
    rect rgb(240, 248, 255)
        Note over Handler,DB: NEW: Enrichment Flow
        Handler->>Enricher: enrichConnectorsWithSocials(connectors, accountId)
        
        Enricher->>DB: selectAccountSocials(accountId)
        DB-->>Enricher: Social profile data (url, username, avatar)
        
        loop For each Connector
            alt connector.isConnected AND slug in [instagram, tiktok]
                Enricher->>Enricher: Match social.profile_url hostname to slug
                opt Hostname matches
                    Enricher->>Enricher: CHANGED: Attach avatar and username
                end
            else connector is not connected OR slug is Google/Other
                Enricher->>Enricher: Skip enrichment
            end
        end
        
        Enricher-->>Handler: Enriched ConnectorInfo[]
    end
    
    Handler-->>Client: 200 OK (JSON with avatar/username fields)
Loading

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

): Promise<ConnectorInfo[]> {
const accountSocials = await selectAccountSocials(accountId);
const socials: SocialRow[] = (accountSocials || [])
.map((item) => (item as any).social as SocialRow | null)
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Custom agent: Enforce Clear Code Style and Maintainability Practices

Rule 1 (strict TypeScript typing) is violated by using any in the social mapping; use the typed social field directly instead of bypassing type checks.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At lib/composio/connectors/enrichConnectorsWithSocials.ts, line 48:

<comment>Rule 1 (strict TypeScript typing) is violated by using `any` in the social mapping; use the typed `social` field directly instead of bypassing type checks.</comment>

<file context>
@@ -0,0 +1,69 @@
+): Promise<ConnectorInfo[]> {
+  const accountSocials = await selectAccountSocials(accountId);
+  const socials: SocialRow[] = (accountSocials || [])
+    .map((item) => (item as any).social as SocialRow | null)
+    .filter((s): s is SocialRow => s !== null);
+
</file context>
Fix with Cubic

expectedHostname: string,
): boolean {
try {
const hostname = new URL(profileUrl).hostname.toLowerCase();
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: new URL(profileUrl) fails for normalized profile URLs stored without protocol, causing social matching to miss valid Instagram/TikTok records.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At lib/composio/connectors/enrichConnectorsWithSocials.ts, line 23:

<comment>`new URL(profileUrl)` fails for normalized profile URLs stored without protocol, causing social matching to miss valid Instagram/TikTok records.</comment>

<file context>
@@ -0,0 +1,69 @@
+  expectedHostname: string,
+): boolean {
+  try {
+    const hostname = new URL(profileUrl).hostname.toLowerCase();
+    return (
+      hostname === expectedHostname || hostname.endsWith(`.${expectedHostname}`)
</file context>
Fix with Cubic

});

// Enrich with social profile data (avatar, username)
const enriched = await enrichConnectorsWithSocials(connectors, accountId);
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Handle enrichment failures gracefully so social-profile lookup errors don’t turn /api/connectors into a 500 when connector data was fetched successfully.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At lib/composio/connectors/getConnectorsHandler.ts, line 49:

<comment>Handle enrichment failures gracefully so social-profile lookup errors don’t turn `/api/connectors` into a 500 when connector data was fetched successfully.</comment>

<file context>
@@ -40,15 +45,19 @@ export async function getConnectorsHandler(request: NextRequest): Promise<NextRe
     });
 
+    // Enrich with social profile data (avatar, username)
+    const enriched = await enrichConnectorsWithSocials(connectors, accountId);
+
     return NextResponse.json(
</file context>
Suggested change
const enriched = await enrichConnectorsWithSocials(connectors, accountId);
const enriched = await enrichConnectorsWithSocials(connectors, accountId).catch(
() => connectors,
);
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant