Skip to content

feat(frontend): match sdk error types casing #4057

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hassan254-prog
Copy link
Contributor

@hassan254-prog hassan254-prog commented May 16, 2025

##Describe the problem and your solution

  • Match sdk error types casing

This PR updates all frontend SDK authentication error type string literals and related documentation from camelCase (e.g., 'missingAuthToken') to snake_case (e.g., 'missing_auth_token') to match industry convention. Changes are made to type definitions, error construction logic, UI error handling, and the SDK reference documentation for consistency and future extensibility.

Key Changes:
• Replaced all camelCase AuthErrorType values with snake_case equivalents in 'packages/frontend/lib/types.ts' and corresponding usage throughout the frontend SDK.
• Updated error instantiation locations and error handling logic to use new snake_case error codes.
• Aligned UI error presentation in Connect UI to expect new error type casing ('window_closed', etc.).
• Revised reference documentation (docs-v2/reference/sdks/frontend.mdx) to match new error codes and descriptions.

Affected Areas:
• Frontend SDK type definitions and error handling ('packages/frontend/lib/types.ts', 'packages/frontend/lib/index.ts')
• Connect UI error display logic ('packages/connect-ui/src/views/Go.tsx')
• Frontend SDK documentation ('docs-v2/reference/sdks/frontend.mdx')

This summary was automatically generated by @propel-code-bot

Copy link

linear bot commented May 16, 2025

@hassan254-prog hassan254-prog self-assigned this May 16, 2025
@hassan254-prog hassan254-prog requested a review from a team May 19, 2025 08:25
Copy link
Collaborator

@bodinsamuel bodinsamuel left a comment

Choose a reason for hiding this comment

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

unfortunately this would be a breaking changes for a lot of customers

@khaliqgant
Copy link
Member

unfortunately this would be a breaking changes for a lot of customers

Indeed. We could do our "normal" deprecation pattern.

  1. Make these additions only
  2. Remove the ones we're replacing from any documentation
  3. Add a deprecation notice to the ones that we will no longer support
  4. Set a deprecation date

@TBonnin TBonnin force-pushed the master branch 3 times, most recently from f519537 to 87a5092 Compare May 27, 2025 20:45
@hassan254-prog
Copy link
Contributor Author

@khaliqgant and @bodinsamuel , I suppose there's no way to deprecate individual string literals within a union type for AuthErrorType. To take a cleaner approach, I thought it best to deprecate AuthError entirely and replace it with a new AuthErrorV2, which now uses enums for better future-proofing. If needed, we can deprecate individual auth error types within the enum moving forward.

legacy?: AuthError;
type: AuthErrorTypeV2;

constructor(message: string, type: AuthErrorTypeV2, legacyType?: AuthErrorType) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

a simpler API would be in my opinion to no pass the legacyType and internally map the AuthErrorTypeV2 to the legacy one (since the legacy one are not gonna evolve anymore). wdyt?

Copy link
Collaborator

@bodinsamuel bodinsamuel left a comment

Choose a reason for hiding this comment

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

Deprecated doesn't raise any alarm in typescript so I wouldn't use that as a safety net. Not entirely sure what does AuthErrorV2 bring since it's still not retro-compatible and still breaking.

If we really want to achieve this, I only see two options:

  • opt-in for new errors and have the two system running together
  • announce breaking change and just go with it

I would just go for later if that's an accepted risk. So maybe your first option was fine but I'm still not sure why we bother tbh


Tegarding enum I would try not to use them more, since even Microsoft acknowledge they are not good. The only annoying part is @deprecated but you can use a regular object or constant playground

@hassan254-prog
Copy link
Contributor Author

Deprecated doesn't raise any alarm in typescript so I wouldn't use that as a safety net. Not entirely sure what does AuthErrorV2 bring since it's still not retro-compatible and still breaking.

If we really want to achieve this, I only see two options:

  • opt-in for new errors and have the two system running together
  • announce breaking change and just go with it

I would just go for later if that's an accepted risk. So maybe your first option was fine but I'm still not sure why we bother tbh

Tegarding enum I would try not to use them more, since even Microsoft acknowledge they are not good. The only annoying part is @deprecated but you can use a regular object or constant playground

AuthErrorV2 introduces the correct casing convention (snake_case) that we’ll be using moving forward. It includes support for future deprecation scenarios. At the same time, we’re maintaining support for the original AuthError to avoid breaking changes for existing customers and to give them time to migrate to AuthErrorV2. The plan is to eventually remove AuthError, but new users will be guided to use AuthErrorV2 via the documentation. This is my first time introducing such a breaking change for users in Nango, I will need proper guidance ☺️ .

@bodinsamuel
Copy link
Collaborator

I understand the new class it's just that it's a breaking change, so there is no need to introduce a new layer if it's also breaking.
What will happen if we merge:

  • People staying before this version = no problem
  • People upgrading = they have to use AuthErrorV2 because AuthError is no longer thrown

If you want to upgrade without breaking change you need to do the opposite, by no changing type and introducing a new type

class AuthError {
 type,
 typeV2
}

But if you do that, that nobody will upgrade since no TS errors will be raised. So that's why I'm saying, maybe the only way is just to create a breaking change and be done with it.

@hassan254-prog hassan254-prog force-pushed the kelvinwari/ext-702-clean-up-frontend-sdk-casing branch from 4f6c19d to 0490112 Compare June 2, 2025 11:23
@hassan254-prog
Copy link
Contributor Author

I understand the new class it's just that it's a breaking change, so there is no need to introduce a new layer if it's also breaking. What will happen if we merge:

  • People staying before this version = no problem
  • People upgrading = they have to use AuthErrorV2 because AuthError is no longer thrown

If you want to upgrade without breaking change you need to do the opposite, by no changing type and introducing a new type

class AuthError {
 type,
 typeV2
}

But if you do that, that nobody will upgrade since no TS errors will be raised. So that's why I'm saying, maybe the only way is just to create a breaking change and be done with it.

Aaah, that makes perfect sense, thanks! I think going for it with the breaking changes is the only way. I've reverted to the initial commit of the PR.

@TBonnin
Copy link
Collaborator

TBonnin commented Jun 2, 2025

what's the plan to release this breaking change?

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.

4 participants