Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 22, 2026

Changes

Profile settings UpdateUserInfo mutation was missing proper error handling to display toast notifications consistently.

  • Error handling: Toast now displays on all mutation failures, including field validation errors (previously only showed for generic errors)
  • Defensive error handling: Added try-catch wrapper around JSON.parse to prevent crashes when error responses are not in expected format
  • Development debugging: Added console warnings (dev-only) to aid debugging of malformed error responses
  • Code quality: Simplified error handling logic and added proper type safety

Technical changes

packages/shared/src/hooks/useUserInfoForm.ts

onError: (err) => {
  if (err?.response?.errors?.length) {
    try {
      const data: ProfileFormHint = JSON.parse(
        err.response.errors[0].message,
      );
      
      Object.entries(data).forEach(([key, value]) => {
        methods.setError(key as keyof UserProfile, {
          type: 'manual',
          message: value,
        });
      });
    } catch (e: unknown) {
      // If parsing fails, log in dev mode for debugging
      if (process.env.NODE_ENV !== 'production') {
        console.warn('Failed to parse error response:', err.response.errors[0].message, e);
      }
    }
  }
  
  displayToast('Failed to update profile');
}

Note: Loading button functionality was added in a separate PR (#5349) and is not part of this change.

Events

No new tracking events.

Experiment

No new experiments.

Manual Testing

Caution

Please make sure existing components are not breaking/affected by this PR

On those affected packages:

  • Have you done sanity checks in the webapp?
  • Have you done sanity checks in the extension?
  • Does this not break anything in companion?
Original prompt

When the UpdateUserInfo mutation fails on updating my profile settings page, there is no error toast message. Additionally there is not spinner on the save button while the UpdateUserInfo mutation is running.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Preview domain

https://copilot-fix-update-user-info-err.preview.app.daily.dev

@vercel
Copy link

vercel bot commented Jan 22, 2026

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

Project Deployment Review Updated (UTC)
daily-webapp Ready Ready Preview Jan 22, 2026 1:45pm

Request Review

Co-authored-by: omBratteng <1681525+omBratteng@users.noreply.github.com>
@CLAassistant
Copy link

CLAassistant commented Jan 22, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ omBratteng
❌ Copilot
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI changed the title [WIP] Fix error handling and loading state on profile settings page Add error toast and loading state to profile settings save Jan 22, 2026
Copilot AI requested a review from omBratteng January 22, 2026 10:05
@omBratteng
Copy link
Member

@copilot Rebase your changes, I added the loading button in a separate PR.
Make sure that any error message is shown correctly on the profile settings page when there is an error, it currently does not.

Wrap JSON.parse in try-catch to prevent crashes when error messages
are not in the expected JSON format. Toast notification will still
be displayed even if parsing fails.
Copy link
Contributor Author

Copilot AI commented Jan 22, 2026

@copilot Rebase your changes, I added the loading button in a separate PR.
Make sure that any error message is shown correctly on the profile settings page when there is an error, it currently does no...

Rebased and removed duplicate loading button change. Added try-catch wrapper around JSON.parse to ensure error toast displays correctly even when error response format is unexpected. (fe63197)

Copilot AI and others added 4 commits January 22, 2026 13:12
Log parsing errors to console to aid debugging when error responses
don't match expected JSON format.

Co-authored-by: omBratteng <1681525+omBratteng@users.noreply.github.com>
Move displayToast call outside if statement since the same message
is shown in all error cases. Also improve logging to include the
original error message for better debugging.

Co-authored-by: omBratteng <1681525+omBratteng@users.noreply.github.com>
Co-authored-by: omBratteng <1681525+omBratteng@users.noreply.github.com>
- Type catch variable as 'unknown' for better type safety
- Only log parsing errors in non-production environments

Co-authored-by: omBratteng <1681525+omBratteng@users.noreply.github.com>
Copilot AI changed the title Add error toast and loading state to profile settings save Fix error toast display for profile settings save Jan 22, 2026
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.

3 participants