Skip to content

fix(nextjs): keep the profile on screen when a profile update fails - #557

Open
DonOmalVindula wants to merge 1 commit into
asgardeo:mainfrom
DonOmalVindula:fix/nextjs-user-profile-update-error
Open

fix(nextjs): keep the profile on screen when a profile update fails#557
DonOmalVindula wants to merge 1 commit into
asgardeo:mainfrom
DonOmalVindula:fix/nextjs-user-profile-update-error

Conversation

@DonOmalVindula

Copy link
Copy Markdown
Contributor

Problem

updateUserProfileAction reports a failed update as {success: false, error, data: {user: {}}} rather than throwing. <UserProfile /> ignored success and passed result.data.user to onUpdateProfile unconditionally, so a rejected update (read-only attribute, expired token, network error) replaced the displayed profile with an empty one and showed nothing. The React SDK keeps the profile and shows the error through BaseUserProfile's error prop.

Fix

  • UserProfile checks the result: on failure it keeps the profile and shows the reason (or the generic user.profile.update.generic.error text) in the profile's error alert; on success it updates the context as before. Errors thrown by the action call are handled the same way.
  • The component-level preferences prop (i18n / theme) is now forwarded to BaseUserProfile, as in the React SDK.
  • updateUserProfileAction returns the underlying error message; it used to prefix it with "Failed to get user profile".

Testing

  • New updateUserProfileAction unit tests for the success and failure results (62 tests pass).
  • pnpm lint and tsc --noEmit for @asgardeo/nextjs. There is no component test setup in this package, so the component change is covered by review.

Changeset included (@asgardeo/nextjs patch).

🤖 Generated with Claude Code

updateUserProfileAction reports failures as a result instead of throwing,
and UserProfile handed the empty user of that result to onUpdateProfile,
which replaced the displayed profile with an empty one and showed no message.

- Show the failure reason through BaseUserProfile's error alert, as the React
  SDK does, and leave the profile untouched.
- Forward the component-level `preferences` to the base component.
- Return the underlying error message from the action (it said "Failed to
  get user profile").

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 31 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 1cf4d22b-4372-480b-b221-f416d8db0abc

📥 Commits

Reviewing files that changed from the base of the PR and between 409ebae and 2fd61be.

📒 Files selected for processing (4)
  • .changeset/nextjs-user-profile-update-error.md
  • packages/nextjs/src/client/components/presentation/UserProfile/UserProfile.tsx
  • packages/nextjs/src/server/actions/__tests__/updateUserProfileAction.test.ts
  • packages/nextjs/src/server/actions/updateUserProfileAction.ts

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.

@asgardeo-github-bot

Copy link
Copy Markdown

🦋 Changeset detected

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

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

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