Skip to content

feat: cut getArtistSocials tasks helper over to /api/artists/{id}/socials with x-api-key#143

Merged
sweetmantech merged 1 commit intomainfrom
feat/tasks-cutover-artist-socials
Apr 18, 2026
Merged

feat: cut getArtistSocials tasks helper over to /api/artists/{id}/socials with x-api-key#143
sweetmantech merged 1 commit intomainfrom
feat/tasks-cutover-artist-socials

Conversation

@arpitgupta1214
Copy link
Copy Markdown
Collaborator

@arpitgupta1214 arpitgupta1214 commented Apr 17, 2026

Summary

Migrate the getArtistSocials tasks helper to the new RESTful nested path GET /api/artists/{id}/socials on recoup-api.vercel.app, and add the required x-api-key auth header.

  • Build URL from NEW_API_BASE_URL (already exported in src/consts.ts) with id as path segment; drop the artist_account_id query param.
  • Send x-api-key: RECOUP_API_KEY header (template: src/recoup/createAccountSandbox.ts). Guard missing key by logging + returning undefined (same failure mode as siblings).
  • Removed dead ARTIST_SOCIALS_API_URL constant — URL now built inline like createAccountSandbox.
  • Zod schema, error handling, and exported ArtistSocialProfile / getArtistSocials types unchanged. Downstream consumers (getBatchArtistSocials, filterScrapableSocials, isScrapableSocial) require no edits.

Draft until the api-side PR adding app/api/artists/[id]/socials/route.ts with auth lands and deploys to production.

Test plan

  • npx tsc --noEmit clean on src/recoup/getArtistSocials.ts
  • pnpm test 165/165 pass
  • grep: zero references to api.recoupable.com/api/artist/socials
  • Post-deploy: live call against prod with a real artist id returns status: "success" with populated socials[]

Summary by cubic

Switch getArtistSocials to the nested endpoint GET /api/artists/{id}/socials and add x-api-key auth to align with the new API.

  • Refactors
    • Build the URL from NEW_API_BASE_URL with id in the path; remove the artist_account_id query param.
    • Send x-api-key from RECOUP_API_KEY; if missing, log and return undefined.
    • Remove the ARTIST_SOCIALS_API_URL constant; Zod schema, types, and downstream consumers remain unchanged.

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

Summary by CodeRabbit

  • Refactor
    • Updated artist socials API integration to use path-based endpoints instead of query parameters.
    • Enhanced configuration management by migrating to centralized environment variables for API credentials.
    • Improved error handling with API key validation and enhanced authentication headers.

…ials with x-api-key

- Build URL from NEW_API_BASE_URL + nested path id (drop artist_account_id query param)
- Send x-api-key: RECOUP_API_KEY header per mono/api auth retrofit
- Guard on missing RECOUP_API_KEY same as createAccountSandbox template
- Zod schema, error handling, exported types unchanged
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 17, 2026

📝 Walkthrough

Walkthrough

The getArtistSocials function migrates from a hardcoded API endpoint with query parameters to a configuration-driven approach using centralized constants. It now constructs requests using a path-based endpoint structure, adds API key header authentication, and includes early validation for missing credentials.

Changes

Cohort / File(s) Summary
API Endpoint Migration
src/recoup/getArtistSocials.ts
Refactors endpoint from query-parameter-based URL to path-based structure, imports NEW_API_BASE_URL and RECOUP_API_KEY from centralized config, adds error guard for missing API key, and updates HTTP headers to include x-api-key authentication.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A rabbit hops through API calls,
No more hardcoded walls!
Config constants guide the way,
With keys and paths in bright display—
The socials flow, authenticated bright! 🎭✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: migrating getArtistSocials to use the new /api/artists/{id}/socials endpoint with x-api-key authentication, which is the primary focus of the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/tasks-cutover-artist-socials

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.

@arpitgupta1214 arpitgupta1214 marked this pull request as ready for review April 18, 2026 17:33
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/recoup/getArtistSocials.ts (1)

49-49: Encode artistAccountId as a URL path segment.

artistAccountId is interpolated directly into the path. Any unexpected character (e.g., /, ?, #, whitespace) would alter routing or silently break the request. The sibling helper getAccountSandboxes already wraps its id with encodeURIComponent; apply the same here for consistency and defense-in-depth.

🛡️ Proposed fix
-    const url = `${NEW_API_BASE_URL}/api/artists/${artistAccountId}/socials`;
+    const url = `${NEW_API_BASE_URL}/api/artists/${encodeURIComponent(
+      artistAccountId
+    )}/socials`;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/recoup/getArtistSocials.ts` at line 49, The URL path is built by
interpolating artistAccountId directly into NEW_API_BASE_URL in
getArtistSocials, which can break routing for characters like /, ?, # or spaces;
update the construction of url in getArtistSocials to wrap artistAccountId with
encodeURIComponent (same approach as getAccountSandboxes) so the artistAccountId
is safely encoded as a path segment before concatenation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/recoup/getArtistSocials.ts`:
- Line 49: The URL path is built by interpolating artistAccountId directly into
NEW_API_BASE_URL in getArtistSocials, which can break routing for characters
like /, ?, # or spaces; update the construction of url in getArtistSocials to
wrap artistAccountId with encodeURIComponent (same approach as
getAccountSandboxes) so the artistAccountId is safely encoded as a path segment
before concatenation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 44883bb5-d8ff-444b-880c-2b925f0cbb42

📥 Commits

Reviewing files that changed from the base of the PR and between b6667c1 and e6e7daa.

📒 Files selected for processing (1)
  • src/recoup/getArtistSocials.ts

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.

1 issue found across 1 file

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="src/recoup/getArtistSocials.ts">

<violation number="1" location="src/recoup/getArtistSocials.ts:49">
P2: Wrap `artistAccountId` in `encodeURIComponent()` to safely embed it as a path segment. The previous query-param approach auto-encoded the value; the new template literal does not, so any ID containing `/`, `?`, or `#` would break the URL.</violation>
</file>

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

try {
const url = new URL(ARTIST_SOCIALS_API_URL);
url.searchParams.set("artist_account_id", artistAccountId);
const url = `${NEW_API_BASE_URL}/api/artists/${artistAccountId}/socials`;
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Apr 18, 2026

Choose a reason for hiding this comment

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

P2: Wrap artistAccountId in encodeURIComponent() to safely embed it as a path segment. The previous query-param approach auto-encoded the value; the new template literal does not, so any ID containing /, ?, or # would break the URL.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/recoup/getArtistSocials.ts, line 49:

<comment>Wrap `artistAccountId` in `encodeURIComponent()` to safely embed it as a path segment. The previous query-param approach auto-encoded the value; the new template literal does not, so any ID containing `/`, `?`, or `#` would break the URL.</comment>

<file context>
@@ -41,14 +40,19 @@ export async function getArtistSocials(
   try {
-    const url = new URL(ARTIST_SOCIALS_API_URL);
-    url.searchParams.set("artist_account_id", artistAccountId);
+    const url = `${NEW_API_BASE_URL}/api/artists/${artistAccountId}/socials`;
 
-    const response = await fetch(url.toString(), {
</file context>
Suggested change
const url = `${NEW_API_BASE_URL}/api/artists/${artistAccountId}/socials`;
const url = `${NEW_API_BASE_URL}/api/artists/${encodeURIComponent(artistAccountId)}/socials`;
Fix with Cubic

@sweetmantech sweetmantech merged commit da35314 into main Apr 18, 2026
3 checks passed
@sweetmantech sweetmantech deleted the feat/tasks-cutover-artist-socials branch April 18, 2026 20:35
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