Skip to content

feat(backend, clerk-js): Deprecate metadata updates in user update methods#8587

Open
brunol95 wants to merge 2 commits into
mainfrom
bruno/user-5312-deprecate-update-user-metadata-fields
Open

feat(backend, clerk-js): Deprecate metadata updates in user update methods#8587
brunol95 wants to merge 2 commits into
mainfrom
bruno/user-5312-deprecate-update-user-metadata-fields

Conversation

@brunol95
Copy link
Copy Markdown
Contributor

@brunol95 brunol95 commented May 18, 2026

Todo

  • update BAPI and FAPI api versions

Description

  • deprecates metadata fields in update user methods and refactors implementation to route to dedicated metadata endpoints
  • adds a new replaceUserMetadata method

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 18, 2026

🦋 Changeset detected

Latest commit: bf5b092

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 20 packages
Name Type
@clerk/backend Minor
@clerk/clerk-js Patch
@clerk/shared Patch
@clerk/astro Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/hono Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/tanstack-react-start Patch
@clerk/testing Patch
@clerk/chrome-extension Patch
@clerk/expo Patch
@clerk/expo-passkeys Patch
@clerk/localizations Patch
@clerk/msw Patch
@clerk/react Patch
@clerk/ui Patch
@clerk/vue Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link
Copy Markdown

vercel Bot commented May 18, 2026

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

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment May 19, 2026 2:02pm

Request Review

@brunol95 brunol95 changed the title deprecate metadata updates in user update methods chore(clerk-js, backend):deprecate metadata updates in user update methods May 18, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 18, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR refactors user metadata update paths across the Clerk JavaScript SDK: it deprecates metadata parameters on updateUser/user.update, adds an RFC 7396 computeMergePatch utility, makes frontend User.update async to conditionally route unsafeMetadata via merge-patch-aware updateMetadata (short-circuiting when unchanged), splits backend updateUser into conditional PATCH (non-metadata) and PUT (metadata), and adds replaceUserMetadata for full metadata replacement. Tests and API/version constant bumps accompany the changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • clerk/javascript#8537: Introduces User.updateMetadata() on the frontend, which this PR uses as the target method for routing deprecated user.update({ unsafeMetadata }) calls.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and accurately summarizes the main change: deprecating metadata updates in user update methods across backend and clerk-js packages.
Description check ✅ Passed The PR description clearly relates to the changeset: it describes deprecating metadata fields in user update methods, refactoring to route to dedicated metadata endpoints, and adding a new replaceUserMetadata method, all of which match the file changes.

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


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

…update

Co-authored-by: Cursor <cursoragent@cursor.com>
@brunol95 brunol95 force-pushed the bruno/user-5312-deprecate-update-user-metadata-fields branch from 640692b to 16fdd04 Compare May 18, 2026 19:56
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 18, 2026

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@8587

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@8587

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@8587

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@8587

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@8587

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@8587

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@8587

@clerk/express

npm i https://pkg.pr.new/@clerk/express@8587

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@8587

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@8587

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@8587

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@8587

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@8587

@clerk/react

npm i https://pkg.pr.new/@clerk/react@8587

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@8587

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@8587

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@8587

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@8587

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@8587

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@8587

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@8587

commit: bf5b092

@brunol95 brunol95 changed the title chore(clerk-js, backend):deprecate metadata updates in user update methods feat(clerk-js, backend):deprecate metadata updates in user update methods May 19, 2026
@brunol95 brunol95 changed the title feat(clerk-js, backend):deprecate metadata updates in user update methods feat(backend, clerk-js): Deprecate metadata updates in user update methods May 19, 2026
@brunol95 brunol95 requested review from a team and wobsoriano May 19, 2026 14:14
Copy link
Copy Markdown
Member

@wobsoriano wobsoriano left a comment

Choose a reason for hiding this comment

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

Left a small suggestion and a question.

Also if possible, I think we should add an e2e test. We can place the test here https://github.com/clerk/javascript/blob/main/integration/tests/unsafeMetadata.test.ts

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's split this into separate changesets so each package changelog stays focused 👍🏼

  1. for backend
  2. for clerk-js and shared

});
}

const patch = computeMergePatch(this.unsafeMetadata, unsafeMetadata);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this preserve replacement semantics if this.unsafeMetadata is not fresh at the moment of the call? Touch-on-focus can refresh the user in common tab-switching flows, but user.update({ unsafeMetadata }) previously sent the caller-provided value as the full replacement regardless of local cache state. With this client-side diff, a stale local value can produce an incomplete patch, or {} and skip the request entirely.

Correct me if Im wrong 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants