-
Notifications
You must be signed in to change notification settings - Fork 0
Sweetmantech/myc 3742 mcp youtube login #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedFailed to post review comments WalkthroughThis PR introduces comprehensive artist profile management with knowledge base uploads to Arweave, fan segment generation using AI, social media link management, and artist-facing data enrichment. It implements web search via Perplexity API and Spotify data integration. It refactors MCP tool response handling with standardized wrappers and adds extensive Supabase database utilities to support the new features. It also adds YouTube authentication token management. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant MCP Server
participant createSegments
participant generateSegments
participant generateArray
participant Supabase
participant Arweave
Client->>MCP Server: Call create_segments tool<br/>(artist_account_id, prompt)
MCP Server->>createSegments: createSegments(args)
createSegments->>Supabase: selectAccounts(artist_account_id)
Supabase-->>createSegments: account + artist name
createSegments->>Supabase: selectSocialFans(artist_account_id)
Supabase-->>createSegments: fans with social details
createSegments->>generateSegments: generateSegments({fans, prompt})
generateSegments->>generateArray: generateArray(SYSTEM_PROMPT, analysis_prompt)
generateArray-->>generateSegments: [GenerateArrayResult]
generateSegments-->>createSegments: segment definitions
createSegments->>Supabase: deleteSegments(artist_account_id)
Supabase-->>createSegments: deleted segments
createSegments->>Supabase: insertSegments(segment_definitions)
Supabase-->>createSegments: inserted segments with IDs
createSegments->>Supabase: insertArtistSegments(associations)
Supabase-->>createSegments: artist_segments records
createSegments->>Supabase: insertFanSegments(fan_associations)
Supabase-->>createSegments: fan_segments records
createSegments-->>MCP Server: successResponse(data)
MCP Server-->>Client: success + segment results
sequenceDiagram
participant Client
participant MCP Server
participant updateArtistProfile
participant Arweave
participant Supabase
Client->>MCP Server: Call update_account_info tool<br/>(artistId, image, name, etc.)
MCP Server->>updateArtistProfile: updateArtistProfile(fields)
updateArtistProfile->>Supabase: selectAccounts(artistId)
Supabase-->>updateArtistProfile: artist account
alt Account not found
updateArtistProfile-->>MCP Server: error
end
updateArtistProfile->>Supabase: updateAccount(name)
Supabase-->>updateArtistProfile: updated account
updateArtistProfile->>Supabase: selectAccountInfo(accountId)
Supabase-->>updateArtistProfile: existing account_info or null
alt account_info exists
updateArtistProfile->>Supabase: updateAccountInfo(fields, deduped knowledges)
else account_info not found
updateArtistProfile->>Supabase: insertAccountInfo(new record)
end
Supabase-->>updateArtistProfile: updated/inserted account_info
updateArtistProfile->>Supabase: selectAccountInfo + selectAccounts (concurrent)
Supabase-->>updateArtistProfile: merged ArtistProfile
updateArtistProfile-->>MCP Server: ArtistProfile
MCP Server-->>Client: success + updated profile
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Areas requiring extra attention:
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional Suggestions:
- The
updateAccountInfofunction call is not checked for errors. If the update fails, the error is silently logged but the function continues and returns the old profile data, making it appear as if the update succeeded.
View Details
📝 Patch Details
diff --git a/lib/artist/updateArtistProfile.ts b/lib/artist/updateArtistProfile.ts
index 9c7cbd0..df874aa 100644
--- a/lib/artist/updateArtistProfile.ts
+++ b/lib/artist/updateArtistProfile.ts
@@ -68,16 +68,22 @@ export async function updateArtistProfile(
infoUpdate.label = label === "" ? null : label;
}
- await updateAccountInfo(artistId, infoUpdate);
+ const updatedAccountInfo = await updateAccountInfo(artistId, infoUpdate);
+ if (!updatedAccountInfo) {
+ throw new Error("Failed to update account info");
+ }
} else {
// Create new account_info
- await insertAccountInfo({
+ const newAccountInfo = await insertAccountInfo({
image: image || null,
instruction: instruction || null,
knowledges: knowledges || null,
label: label === "" ? null : label || null,
account_id: artistId,
});
+ if (!newAccountInfo) {
+ throw new Error("Failed to create account info");
+ }
}
// Fetch and return the latest account and account_info
Analysis
Silent data loss in updateArtistProfile when database operations fail
What fails: The updateArtistProfile() function in lib/artist/updateArtistProfile.ts does not check the return values of updateAccountInfo() (line 71) and insertAccountInfo() (line 76). When these database operations fail, they return null but the function continues execution, refetches the old/unchanged data, and returns it as if the update succeeded.
How to reproduce:
- Call
updateArtistProfile(artistId, image, name, instruction, label, knowledges)where the account_info record exists - Inject a failure in the Supabase database layer (or simulate network failure) causing
updateAccountInfoto fail - The function logs the error to console but continues execution
selectAccountInfois called at line 85 and returns the OLD (unchanged) data from the database- Function returns
success: truewith old data
Result: The caller receives the old profile data with no indication that the update failed. Changes are not persisted to the database, but the caller believes they succeeded.
Expected behavior: Per the pattern established in lines 46-49 where updateAccount is checked with if (!updatedAccount) throw new Error(), the updateAccountInfo call should also check its return value and throw an error on failure, preventing the function from returning false success.
Root cause: Unchecked return values on database operation functions that can fail and return null:
updateAccountInfo()returnsTables<"account_info"> | nullinsertAccountInfo()returnsTables<"account_info"> | null
Both log errors but do not throw, requiring the caller to check the return value. The updateArtistProfile function failed to do this check, creating a silent failure scenario.
View Details
📝 Patch Details
diff --git a/lib/artist/updateArtistSocials.ts b/lib/artist/updateArtistSocials.ts
index 12fc25c..0671f21 100644
--- a/lib/artist/updateArtistSocials.ts
+++ b/lib/artist/updateArtistSocials.ts
@@ -32,7 +32,12 @@ export async function updateArtistSocials(
// Delete existing social for this platform type if it exists
if (existingSocial && existingSocial.social?.id) {
- await deleteAccountSocial(artistId, existingSocial.social.id);
+ const deleteSuccess = await deleteAccountSocial(artistId, existingSocial.social.id);
+ if (!deleteSuccess) {
+ throw new Error(
+ `Failed to delete existing account social for artist ${artistId} and social ${existingSocial.social.id}`,
+ );
+ }
}
// Insert new social if URL provided
@@ -43,7 +48,12 @@ export async function updateArtistSocials(
(as: AccountSocialWithSocial) => as.social_id === social.id,
);
if (!existing) {
- await insertAccountSocial(artistId, social.id);
+ const insertResult = await insertAccountSocial(artistId, social.id);
+ if (!insertResult) {
+ throw new Error(
+ `Failed to insert account social for artist ${artistId} and social ${social.id}`,
+ );
+ }
}
} else {
// Create new social record
@@ -54,7 +64,12 @@ export async function updateArtistSocials(
},
]);
if (newSocials.length > 0) {
- await insertAccountSocial(artistId, newSocials[0].id);
+ const insertResult = await insertAccountSocial(artistId, newSocials[0].id);
+ if (!insertResult) {
+ throw new Error(
+ `Failed to insert account social for artist ${artistId} and social ${newSocials[0].id}`,
+ );
+ }
}
}
}
Analysis
Unchecked database operation failures in updateArtistSocials allows inconsistent responses
What fails: updateArtistSocials() ignores return values from deleteAccountSocial() and insertAccountSocial(), logging errors but continuing execution and returning a success response even when database operations fail.
How to reproduce:
- Call updateArtistSocials() with artistId and profileUrls to update artist socials
- When deleteAccountSocial() or insertAccountSocial() encounters a database error (e.g., due to constraint violation, permission error, or connection issue), the function returns false/null respectively
- The error is logged to console but the function continues execution
- updateArtistSocials() completes and returns the current state of socials from the database
- The MCP tool (registerUpdateArtistSocialsTool) receives the data and returns
success: truewith the incomplete/unchanged social relationships - Caller believes the update succeeded when it actually failed
Result: The database operation failures are silently ignored. If deleteAccountSocial fails, the old social isn't removed. If insertAccountSocial fails, the new social isn't linked. The caller receives a success response with data that doesn't reflect what was requested.
Expected: When deleteAccountSocial or insertAccountSocial fail, an error should be thrown and propagated to the caller, preventing the function from returning a false success response.
References:
- deleteAccountSocial returns boolean with false on error (lib/supabase/account_socials/deleteAccountSocial.ts line 19)
- insertAccountSocial returns null on error (lib/supabase/account_socials/insertAccountSocial.ts line 22)
- Three locations in updateArtistSocials where return values are not checked (lines 35, 46, 57)
- Similar pattern in other codebase functions like insertAccount (lib/supabase/accounts/insertAccount.ts) which properly throw errors on failure
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.