fix: use @clerk/backend for backfill script clerk client#6056
Conversation
❌ 1 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
⚡ Lighthouse — Web
Tested URL: https://pr-6056-www.vm6.ai/ · Full report |
The backfill script runs outside Next.js runtime via tsx, so `createClerkClient` from `@clerk/nextjs/server` is not available at ESM runtime (only re-exported in type declarations). Switch to importing directly from `@clerk/backend` which is the actual source package. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Dry-run mode should still read from Clerk API to show what would be backfilled. Previously it skipped Clerk initialization entirely, making dry-run output useless (0 processed). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1e7d8bf to
7147476
Compare
Code Review: PR #6056SummaryThis PR fixes a runtime import error in the backfill script ( Two well-separated commits:
Key FindingsCritical Issues (P0)
High Priority (P1)
Testing ReviewCoverage
Convention Compliance
Testing Verdict: AdequateExisting tests cover all changed behavior. The import fix is a runtime environment issue (tsx vs Next.js) that wouldn't be caught by vitest-based tests, but the PR description confirms manual verification ( Bad Smell AnalysisAll 17 bad smell categories checked — zero violations. The PR actually improves code quality:
RecommendationsNo action items. This is a clean, well-scoped bug fix. Verdict: LGTMFull review details: |
Summary
createClerkClientimport in backfill script — the script runs viatsxoutside Next.js runtime, so@clerk/nextjs/serverdoesn't exportcreateClerkClientat ESM runtime (only in type declarations)@clerk/backendwhich is the actual source package@clerk/backendas explicit dependencyContext
The backfill script (#5972, PR #5973) was merged with
import { createClerkClient } from "@clerk/nextjs/server"which fails at runtime:Test plan
tsx scripts/migrations/005-backfill-clerk-metadata/backfill.tsruns successfully (dry-run mode)🤖 Generated with Claude Code