Skip to content

Conversation

@ryanbonial
Copy link
Member

@ryanbonial ryanbonial commented Oct 22, 2025

Description

This PR adds utility functions for handling client errors in the authentication flow. It exports several functions from the auth/utils module to help extract and interpret error information from ClientError objects. The main additions include:

  • Added a function to specifically detect "projectUserNotFoundError" errors
  • Updated the LoginError component to use these new utilities for better error handling
  • Improved the user experience by conditionally showing retry CTAs based on the error type
  • Exported utility functions for extracting API error bodies, types, and descriptions from ClientError objects
CleanShot 2025-10-22 at 14 25 59@2x

What to review

  • The new utility functions in auth/utils.ts for handling ClientError objects
  • The exports added to the core package
  • The implementation in LoginError component that uses these utilities to provide better error messages
  • The conditional rendering of the retry CTA based on error type

Testing

Test by:

  1. Change the Kitchensink config to { projectId: 'txacgfm1', dataset: 'production' },
  2. Set verifyOrganization={false} prop on the SDKProvider component in the SanityApp
  3. Run pnpm run deploy:kitchensink
  4. Visit https://www.sanity.io/@oblZgbTFj/application/wkyoigmzawwnnwx458zgoh46/document-list
  5. Observe error message instead of endless rerendering and token refreshing

Fun gif

not found

@ryanbonial ryanbonial requested a review from a team as a code owner October 22, 2025 20:28
@ryanbonial ryanbonial requested a review from rexxars October 22, 2025 20:28
@vercel
Copy link

vercel bot commented Oct 22, 2025

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

Project Deployment Preview Comments Updated (UTC)
sdk-docs Ready Ready Preview Comment Oct 22, 2025 8:29pm
sdk-kitchensink-react Ready Ready Preview Comment Oct 22, 2025 8:29pm

Copy link
Member

@cngonzalez cngonzalez left a comment

Choose a reason for hiding this comment

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

Code itself looks fine to me.

Not really relevant to this PR, I don't think, but I was following your steps to verify, and changed the devConfigs to the project you mentioned. I deployed at that point, and did get the project user not found for user ID "gdaoiCJFz" in project "txacgfm1".

There's also mention of adding a verifyOrganization=false to the SDKProvider in Kitchensink. As far as I can tell there is no SDKProvider in Kitchensink. I added it manually, something like the below in App.tsx:

    <ThemeProvider theme={theme}>
      <SanityApp fallback={<Spinner />} config={devConfigs}>
        <SDKProvider config={devConfigs} fallback={<Spinner />} verifyOrganization={false}>
        // ...etc

and re-deployed. I ended up getting this error: Project txacgfm1 belongs to Organization oSyH1iET5, but the Dashboard has Organization oblZgbTFj selected

Which is the opposite of what I would expect. Not a blocker for this PR, just making a note of it.

@ryanbonial ryanbonial merged commit 1668657 into main Oct 27, 2025
20 checks passed
@ryanbonial ryanbonial deleted the DASH-941/catch-projectUserNotFoundError branch October 27, 2025 14:18
@squiggler squiggler bot mentioned this pull request Oct 27, 2025
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