Skip to content

Conversation

@sweetmantech
Copy link
Collaborator

Summary

Test plan

  • All 9 unit tests pass in Recoup-Chat
  • Build succeeds

🤖 Generated with Claude Code

sweetmantech and others added 2 commits January 15, 2026 08:56
Update lib/createArtist.tsx to call the migrated /api/artist/create
endpoint on recoup-api instead of the local endpoint.

Related to MYC-3924: Migrate /api/artist/create REST endpoint

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Updated to call the new REST-compliant POST /api/artist endpoint with JSON
body instead of GET /api/artist/create with query params.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@vercel
Copy link

vercel bot commented Jan 15, 2026

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

Project Deployment Review Updated (UTC)
recoup-chat Ready Ready Preview Jan 15, 2026 2:08pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 15, 2026

Warning

Rate limit exceeded

@sweetmantech has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 2 minutes and 41 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between 55cc45a and 0626b92.

📒 Files selected for processing (1)
  • lib/createArtist.tsx

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

const response = await fetch(
`/api/artist/create?name=${encodeURIComponent(name)}&account_id=${account_id}`,
);
const response = await fetch(`${NEW_API_BASE_URL}/api/artist`, {
Copy link

Choose a reason for hiding this comment

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

The code doesn't check if the API response was successful before attempting to parse and access data.artist, which deviates from the established error-handling pattern used throughout the codebase. This could cause the function to return undefined instead of null when the API request fails with an HTTP error.

View Details
📝 Patch Details
diff --git a/lib/createArtist.tsx b/lib/createArtist.tsx
index 36e1565d..84f82698 100644
--- a/lib/createArtist.tsx
+++ b/lib/createArtist.tsx
@@ -9,10 +9,15 @@ const createArtist = async (name: string, account_id: string) => {
       },
       body: JSON.stringify({ name, account_id }),
     });
-    const data = await response.json();
 
+    if (!response.ok) {
+      return null;
+    }
+
+    const data = await response.json();
     return data.artist;
   } catch (error) {
+    console.error(error);
     return null;
   }
 };

Analysis

Missing response.ok check in createArtist() allows undefined return on API errors

What fails: lib/createArtist.tsx doesn't check response.ok before parsing JSON, causing the function to return undefined instead of null when the API returns HTTP error status codes with valid JSON responses.

How to reproduce:

// In lib/createArtist.tsx (before fix):
const createArtist = async (name: string, account_id: string) => {
  try {
    const response = await fetch(` 

The API endpoint (app/api/artist/create/route.ts) returns error responses without an artist field:

  • Status 400: { message: "Missing required parameters: name and account_id" }
  • Status 500: { message: "Failed to create artist" }
  • Status 400 on catch: { message: "..." }

Result: Function inconsistently returns undefined for API errors, while all 49+ similar API calls in the codebase use the response.ok pattern to return null on errors.

Expected: Function should check response.ok before attempting to parse response (following the established pattern in lib/getFanSegments.tsx, lib/getConversations.tsx, lib/getHandles.tsx, and 46+ other files).

Fix applied: Added if (!response.ok) return null; check after fetch, consistent with codebase patterns. Also restored console.error(error) logging in catch block for debugging visibility.

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.

2 participants