Skip to content

release: feat(socials) — promote POST /api/socials/{id}/scrape to main (#459) - #467

Merged
sweetmantech merged 1 commit into
mainfrom
test
Apr 21, 2026
Merged

release: feat(socials) — promote POST /api/socials/{id}/scrape to main (#459)#467
sweetmantech merged 1 commit into
mainfrom
test

Conversation

@sweetmantech

@sweetmantechsweetmantech commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Promote #459 (feat: migrate POST /api/social/scrape to /api/socials/{id}/scrape with auth) from test to main.

Squash of #459 on test: 770a9f3.

Test plan

🤖 Generated with Claude Code


Summary by cubic

Moves social scraping to POST /api/socials/{id}/scrape with auth and artist-based access checks, replacing POST /api/social/scrape. Response stays { runId, datasetId }; adds strict validation and test coverage.

  • Migration

    • Use POST /api/socials/{id}/scrape (UUID in path). No request body.
    • Include valid auth; unauthorized or no access returns 401/403.
    • Remove calls to POST /api/social/scrape.
  • Refactors

    • Reworked selectAccountSocials to accept { accountId?, socialId?, offset?, limit? } and throw on DB errors; updated all call sites.
    • Added validatePostSocialScrapeRequest for UUID, auth, existence, and artist-access checks.
    • Removed legacy route and body validator; added tests for handler and validator covering 200/400/401/403/404/500.

Written for commit 770a9f3. Summary will update on new commits.

…h auth (#459)
* feat: migrate POST /api/social/scrape to /api/socials/{id}/scrape with auth
Port the social scrape endpoint to the RESTful nested-plural path used
throughout mono/api and retrofit authentication.
- New route: app/api/socials/[id]/scrape/route.ts (async params)
- New validator: lib/socials/validatePostSocialScrapeRequest.ts
bundles path-id UUID validation + validateAuthContext + access
check against the social's owning artist accounts (via
account_socials). Falls back to auth-only when the social has no
linked accounts.
- Refactor postSocialScrapeHandler to (request, id) signature
- New helper: lib/supabase/account_socials/selectAccountSocialsBySocialId.ts
- Delete legacy app/api/social/scrape/route.ts and
lib/socials/validateSocialScrapeBody.ts
- Tests under lib/socials/__tests__/ covering 200/400/401/403/404/500
Response body { runId, datasetId } preserved byte-for-byte.
* fix: enforce social access check + direct z.object schema + infer account_socials row type
- validatePostSocialScrapeRequest: return 403 when social has no linked
accounts instead of the previous auth-only fallback; also honor direct
membership when the caller owns the social. Admin bypass still flows
through checkAccountArtistAccess.
- Change postSocialScrapeParamsSchema to a direct z.object(...) and infer
PostSocialScrapeParams from it.
- selectAccountSocialsBySocialId: drop hand-written AccountSocial return
type; cast the client to SupabaseClient<Database> locally so the row
type flows from the generated Database types.
- Tests: cover the new 403 paths (no links, links null) and the direct
membership allow-through.
* fix: type serverClient at source; throw on DB error in selectAccountSocialsBySocialId
- serverClient: type `createClient<Database>` at declaration so every
consumer gets row-type inference without local casts.
- selectAccountSocialsBySocialId: drop the `as SupabaseClient<Database>`
cast, throw on DB error instead of returning `null`, and tighten the
return type to `Tables<"account_socials">[]` (no more `| null`).
- validatePostSocialScrapeRequest: remove `?? []` fallback so DB errors
propagate to the route handler's 500 path instead of masquerading as a
403 "no owners" response.
- Tests: replace the "helper returns null -> 403" case with a "helper
throws -> propagates" case.
- selectAccountCatalogs: fix stale type annotation for `catalogs`
relation (1:1, not array) that was hidden by the untyped client.
* refactor: drop manual Tables type; rely on serverClient inference
* revert: drop unrelated selectAccountCatalogs type fix from this PR
Splitting into standalone prep PR — the catalogs relation type was
already wrong (1:1 typed as array); it only surfaced here because
typing serverClient made inference real. Handling separately so this
PR stays scoped to the social scrape endpoint migration.
* refactor: drop manual types in selectAccountCatalogs; rely on serverClient inference
Collateral to typing serverClient: instead of hand-writing
AccountCatalogWithCatalog (previously wrong — catalogs relation is 1:1,
not an array), let the inferred return type flow from the typed
supabase client. Matches the pattern now used in
selectAccountSocialsBySocialId.
* restore: JSDoc on selectAccountCatalogs
* docs: restore JSDoc on selectAccountSocialsBySocialId
* refactor: extract checkAccountSocialAccess helper; collapse inline access walk
* refactor: fold social-id filter into selectAccountSocials; inline access check
- selectAccountSocials now takes { accountId?, socialId?, offset?, limit? }
options, covering both the owner-side listing and the reverse social-id
lookup. Drops the separate selectAccountSocialsBySocialId helper.
- Inlines checkAccountSocialAccess back into validatePostSocialScrapeRequest;
the validator is currently the only caller, so the domain helper added
premature indirection. Will extract again when a second endpoint needs it.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* refactor: drop dead direct-ownership branch from scrape access check
Socials are always owned by artist accounts, never directly by the caller's
user account — the owningAccountIds.includes(callerId) branch could never
fire. Access is gated entirely through checkAccountArtistAccess against
each owning artist.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* refactor: use shared errorResponse + validationErrorResponse helpers
Drop the local errorResponse wrapper in validatePostSocialScrapeRequest —
the codebase already exports errorResponse (lib/networking/) and
validationErrorResponse (lib/zod/) with the same envelope.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
@vercel

vercelBot commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

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

ProjectDeploymentActionsUpdated (UTC)
apiBuildingBuildingPreviewApr 21, 2026 11:19pm

Request Review

@coderabbitai

Copy link
Copy Markdown

Warning

Rate limit exceeded

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

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 16 minutes and 37 seconds.

⌛ 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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 75183af8-a053-441d-a465-a4f9e293e050

📥 Commits

Reviewing files that changed from the base of the PR and between 41a014a and 770a9f3.

⛔ Files ignored due to path filters (2)
  • lib/socials/__tests__/postSocialScrapeHandler.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
  • lib/socials/__tests__/validatePostSocialScrapeRequest.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
📒 Files selected for processing (9)
  • app/api/social/scrape/route.ts
  • app/api/socials/[id]/scrape/route.ts
  • lib/artist/getArtistSocials.ts
  • lib/artist/postArtistSocialsScrapeHandler.ts
  • lib/artist/updateArtistSocials.ts
  • lib/socials/postSocialScrapeHandler.ts
  • lib/socials/validatePostSocialScrapeRequest.ts
  • lib/socials/validateSocialScrapeBody.ts
  • lib/supabase/account_socials/selectAccountSocials.ts
✨ Finishing Touches
🧪 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 c2bde22 into mainApr 21, 2026
5 of 6 checks passed
@sweetmantechsweetmantech mentioned this pull request Apr 23, 2026
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