Skip to content

chore: sync test to main (incl. PR 452 artist-socials rename) - #455

Merged
sweetmantech merged 11 commits into
mainfrom
test
Apr 18, 2026
Merged

chore: sync test to main (incl. PR 452 artist-socials rename)#455
sweetmantech merged 11 commits into
mainfrom
test

Conversation

@sweetmantech

@sweetmantechsweetmantech commented Apr 18, 2026

Copy link
Copy Markdown
Contributor

Release-sync testmain.

Included

Verification

Smoke-tested on the PR 452 preview deployment: all edge cases (401/403/400) and happy-path (empty + 3-item paginated) return expected responses. See #452 (comment).

Auto-generated release PR.


Summary by cubic

Syncs test into main and brings in #452 to rename the artist socials API to /api/artists/{id}/socials with required auth. Adds path/query validation and access checks; removes the old route and updates the MCP tool; response schema stays the same.

  • Migration
    • Use GET /api/artists/{id}/socials (path param id); remove artist_account_id query.
    • Send x-api-key or Authorization: Bearer header.
    • Pagination is unchanged: page (default 1), limit (default 20, max 100).
    • Errors: 400 invalid params, 401 missing/invalid auth, 403 no access, 404 artist not found.

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

Summary by CodeRabbit

  • API Updates
    • Restructured the artist socials endpoint to utilize dynamic routing with artist identifiers in the URL path, improving overall API consistency and RESTful design patterns.
    • Enhanced validation logic for artist social media requests, including improved error detection and handling for invalid or malformed inputs.

arpitgupta1214and others added 11 commits April 18, 2026 00:05
Move the artist socials route to the RESTful nested path and require
authentication. The handler now takes `(request, id)` and delegates to a
new bundled validator that checks UUID path param, optional page/limit
query, and `validateAuthContext`. Response body is byte-identical.
- Add app/api/artists/[id]/socials/route.ts (awaits params, extracts id)
- Add lib/artist/validateGetArtistSocialsRequest.ts (path + query + auth)
- Refactor lib/artist/getArtistSocialsHandler.ts to accept (request, id)
- Decouple lib/artist/getArtistSocials.ts from old validator type
- Update MCP tool to define its own input schema (no shared import)
- Delete app/api/artist/socials/route.ts and lib/artist/validateArtistSocialsQuery.ts
- Add tests covering invalid UUID, invalid page/limit, 401 missing auth,
happy path with default and explicit pagination, 500 error path
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Address review feedback on PR #452:
1. DRY MCP tool schema: extract a single source of truth
(GET_ARTIST_SOCIALS_PAGINATION_DEFAULTS) in
validateGetArtistSocialsRequest.ts and export the MCP-shaped
getArtistSocialsToolSchema from the same file. The MCP tool now
imports both, removing the duplicated literals (1, 20, 100,
"artist_account_id" description).
2. Enforce access control: after validateAuthContext, call
selectAccounts(artistAccountId) -> 404 if missing, then
checkAccountArtistAccess(requesterAccountId, artistAccountId) ->
403 if denied. Mirrors the validateDeleteArtistRequest pattern.
Tests: add 404-not-found and 403-denied cases; mock selectAccounts
and checkAccountArtistAccess for happy-path defaults so prior cases
still pass. 8 validator tests + 4 handler tests green; full suite
333 files / 2103 tests pass.
feat: migrate /api/artist/socials → /api/artists/{id}/socials with auth
@vercel

vercelBot commented Apr 18, 2026

Copy link
Copy Markdown
Contributor

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

ProjectDeploymentActionsUpdated (UTC)
recoup-apiReadyReadyPreviewApr 18, 2026 5:01pm

Request Review

@coderabbitai

coderabbitaiBot commented Apr 18, 2026

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR refactors the artist socials endpoint from query-based parameter extraction to dynamic route-based parameter handling. The validation flow is restructured to integrate authentication context, artist account resolution, and access control checks within a new consolidated validator, replacing the previous query-only approach.

Changes

Cohort / File(s)Summary
Route Handler
app/api/artists/[id]/socials/route.ts
Updated GET handler to extract artist ID from route parameters instead of query strings, forwarding id to the handler as a second argument.
Validation & Authorization
lib/artist/validateGetArtistSocialsRequest.ts, lib/artist/validateArtistSocialsQuery.ts
Replaced query-only validator with comprehensive request validator that handles account lookup, authentication context validation, artist ownership verification, and pagination parameter parsing.
Handler & Core Logic
lib/artist/getArtistSocialsHandler.ts, lib/artist/getArtistSocials.ts
Updated handler signature to accept id parameter and invoke new async validator; adjusted parameter types to GetArtistSocialsParams schema-driven structure.
Tool Integration
lib/mcp/tools/artistSocials/registerGetArtistSocialsTool.ts
Migrated tool input schema from artistSocialsQuerySchema to getArtistSocialsParamsSchema and simplified handler to a concise arrow function.

Sequence Diagram(s)

sequenceDiagram
actor Client
participant Route as Route Handler
participant Validator as validateGetArtistSocialsRequest
participant Auth as Auth Context
participant Accounts as Account Store
participant Access as Access Checker
participant Handler as getArtistSocialsHandler
participant Logic as getArtistSocials
Client->>Route: GET /api/artists/{id}/socials?page=1&limit=20
Route->>Validator: validateGetArtistSocialsRequest(request, id)
Validator->>Validator: Parse & validate pagination params
Validator->>Auth: validateAuthContext()
Auth-->>Validator: Auth context or error response
alt Auth Failed
Validator-->>Route: NextResponse (error)
Route-->>Client: 403/401 JSON error
else Auth Success
Validator->>Accounts: selectAccounts(id)
Accounts-->>Validator: Artist account or null
alt Account Not Found
Validator-->>Route: NextResponse 404
Route-->>Client: 404 JSON error
else Account Found
Validator->>Access: checkAccountArtistAccess()
Access-->>Validator: Access granted or denied
alt Access Denied
Validator-->>Route: NextResponse 403
Route-->>Client: 403 JSON error
else Access Granted
Validator-->>Route: GetArtistSocialsParams (validated)
Route->>Handler: getArtistSocialsHandler(request, id)
Handler->>Logic: getArtistSocials(params)
Logic-->>Handler: Result {status, data}
Handler-->>Route: NextResponse (with CORS headers)
Route-->>Client: 200 JSON {socials, pagination}
end
end
end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🛤️ From query strings to routes so clean,
Parameters dance where paths convene,
Auth checks guard the artist's gate,
Access flows through steps ornate,
A migration mapped with SOLID grace. ✨

🚥 Pre-merge checks | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Solid & Clean Code⚠️ WarningThe pull request violates Single Responsibility Principle by consolidating multiple concerns in validation logic and bypassing security in MCP tool without access control checks.Refactor validation into reusable helpers, update MCP tool to use resolveAccountId() and checkAccountArtistAccess() with proper error handling via getToolResultError().

✏️ 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 test

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.

@sweetmantech
sweetmantech merged commit 2a20cfa into mainApr 18, 2026
6 of 7 checks passed
Sign up for freeto 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

@sweetmantech@arpitgupta1214