Skip to content
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

feat: Render okta errors based on error param #3196

Merged
merged 6 commits into from
Sep 16, 2024
Merged

feat: Render okta errors based on error param #3196

merged 6 commits into from
Sep 16, 2024

Conversation

RulaKhaled
Copy link
Contributor

Description

Surfacing okta errors, a full list of the error codes can be found here: https://developer.okta.com/docs/reference/error-codes/#example-errors-for-openid-connect-and-social-login

issue: codecov/engineering-team#2347

PS. The design was discussed with Kyle and dismiss button visibility in dark mode/light will be handled in a different issue.

Notable Changes

  • Added a new variant for the top banner
  • Created new top banners

Screenshots

Screenshot 2024-09-13 at 10 45 37 AM Screenshot 2024-09-13 at 1 49 49 PM

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

@codecov-staging
Copy link

codecov-staging bot commented Sep 13, 2024

Bundle Report

Changes will increase total bundle size by 1.97kB ⬆️

Bundle name Size Change
gazebo-staging-array-push 6.0MB 1.97kB ⬆️

Copy link

codecov bot commented Sep 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.14%. Comparing base (ddfaa8f) to head (721e5aa).
Report is 8 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff                @@
##               main      #3196        +/-   ##
================================================
+ Coverage   98.13000   98.14000   +0.01000     
================================================
  Files           935        932         -3     
  Lines         14510      14473        -37     
  Branches       3968       3871        -97     
================================================
- Hits          14240      14204        -36     
+ Misses          265        264         -1     
  Partials          5          5                
Files with missing lines Coverage Δ
...hared/GlobalTopBanners/OktaBanners/OktaBanners.tsx 100.00% <100.00%> (ø)
...alTopBanners/OktaErrorBanners/OktaErrorBanners.tsx 100.00% <100.00%> (ø)
.../shared/GlobalTopBanners/OktaErrorBanners/enums.ts 100.00% <100.00%> (ø)
src/ui/TopBanner/TopBanner.tsx 100.00% <ø> (ø)

... and 24 files with indirect coverage changes

Components Coverage Δ
Assets 53.48% <ø> (ø)
Layouts 98.87% <ø> (ø)
Pages 98.89% <ø> (+0.05%) ⬆️
Services 99.41% <ø> (ø)
Shared 99.65% <100.00%> (+0.14%) ⬆️
UI 94.56% <ø> (-0.11%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ddfaa8f...721e5aa. Read the comment docs.

Copy link

codecov bot commented Sep 13, 2024

Bundle Report

Changes will increase total bundle size by 267 bytes (0.0%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
gazebo-production-array-push 6.0MB 267 bytes ⬆️

Copy link

codecov-public-qa bot commented Sep 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.14%. Comparing base (ddfaa8f) to head (721e5aa).
Report is 7 commits behind head on main.

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3196   +/-   ##
=======================================
  Coverage   98.13%   98.14%           
=======================================
  Files         935      932    -3     
  Lines       14510    14473   -37     
  Branches     3968     3871   -97     
=======================================
- Hits        14240    14204   -36     
+ Misses        265      264    -1     
  Partials        5        5           
Files Coverage Δ
...hared/GlobalTopBanners/OktaBanners/OktaBanners.tsx 100.00% <100.00%> (ø)
...alTopBanners/OktaErrorBanners/OktaErrorBanners.tsx 100.00% <100.00%> (ø)
.../shared/GlobalTopBanners/OktaErrorBanners/enums.ts 100.00% <100.00%> (ø)
src/ui/TopBanner/TopBanner.tsx 100.00% <ø> (ø)

... and 24 files with indirect coverage changes

Components Coverage Δ
Assets 53.48% <ø> (ø)
Layouts 98.87% <ø> (ø)
Pages 98.89% <ø> (+0.05%) ⬆️
Services 99.41% <ø> (ø)
Shared 99.65% <100.00%> (+0.14%) ⬆️
UI 94.56% <ø> (-0.11%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ddfaa8f...721e5aa. Read the comment docs.

@codecov-notifications
Copy link

codecov-notifications bot commented Sep 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3196   +/-   ##
=======================================
  Coverage   98.13%   98.14%           
=======================================
  Files         935      932    -3     
  Lines       14510    14473   -37     
  Branches     3886     3952   +66     
=======================================
- Hits        14240    14204   -36     
+ Misses        265      264    -1     
  Partials        5        5           
Files Coverage Δ
...hared/GlobalTopBanners/OktaBanners/OktaBanners.tsx 100.00% <100.00%> (ø)
...alTopBanners/OktaErrorBanners/OktaErrorBanners.tsx 100.00% <100.00%> (ø)
.../shared/GlobalTopBanners/OktaErrorBanners/enums.ts 100.00% <100.00%> (ø)
src/ui/TopBanner/TopBanner.tsx 100.00% <ø> (ø)

... and 24 files with indirect coverage changes

Components Coverage Δ
Assets 53.48% <ø> (ø)
Layouts 98.87% <ø> (ø)
Pages 98.89% <ø> (+0.05%) ⬆️
Services 99.41% <ø> (ø)
Shared 99.65% <100.00%> (+0.14%) ⬆️
UI 94.56% <ø> (-0.11%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ddfaa8f...721e5aa. Read the comment docs.

@codecov-qa
Copy link

codecov-qa bot commented Sep 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.14%. Comparing base (ddfaa8f) to head (721e5aa).
Report is 8 commits behind head on main.

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3196   +/-   ##
=======================================
  Coverage   98.13%   98.14%           
=======================================
  Files         935      932    -3     
  Lines       14510    14473   -37     
  Branches     3973     3957   -16     
=======================================
- Hits        14240    14204   -36     
+ Misses        265      264    -1     
  Partials        5        5           
Files with missing lines Coverage Δ
...hared/GlobalTopBanners/OktaBanners/OktaBanners.tsx 100.00% <100.00%> (ø)
...alTopBanners/OktaErrorBanners/OktaErrorBanners.tsx 100.00% <100.00%> (ø)
.../shared/GlobalTopBanners/OktaErrorBanners/enums.ts 100.00% <100.00%> (ø)
src/ui/TopBanner/TopBanner.tsx 100.00% <ø> (ø)

... and 24 files with indirect coverage changes

Components Coverage Δ
Assets 53.48% <ø> (ø)
Layouts 98.87% <ø> (ø)
Pages 98.89% <ø> (+0.05%) ⬆️
Services 99.41% <ø> (ø)
Shared 99.65% <100.00%> (+0.14%) ⬆️
UI 94.56% <ø> (-0.11%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ddfaa8f...721e5aa. Read the comment docs.

@codecov-releaser
Copy link
Contributor

codecov-releaser commented Sep 13, 2024

✅ Deploy preview for gazebo ready!

Previews expire after 1 month automatically.

Storybook

Commit Created Cloud Enterprise
078a448 Fri, 13 Sep 2024 12:15:59 GMT Expired Expired
3d6ee2d Fri, 13 Sep 2024 12:44:51 GMT Expired Expired
3d6ee2d Fri, 13 Sep 2024 12:50:20 GMT Expired Expired
baae551 Fri, 13 Sep 2024 14:23:25 GMT Expired Expired
8fd0ac1 Mon, 16 Sep 2024 08:28:20 GMT Expired Expired
721e5aa Mon, 16 Sep 2024 14:59:34 GMT Cloud Enterprise

if (error in errorMessages) {
return errorMessages[error as keyof typeof errorMessages]
}
return 'An unknown error occurred. Please try again or contact support.'
Copy link
Contributor

Choose a reason for hiding this comment

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

We could log this to Sentry via Sentry.captureMessage and include the error type so we can keep tabs on cases we might have missed (or if they change for some reason)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point

Copy link
Contributor

Choose a reason for hiding this comment

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

Another thing you may want to add in alongside the fingerprint is a tag. I added one to the prismLanguageMapper capture message and this is what it provides in the Sentry UI:

Screenshot 2024-09-16 at 09 20 16

And the code is pretty simple to add in:

Sentry.captureMessage(`Unsupported language type for filename ${fileName}`, {
  fingerprint: ['unsupported-prism-language'],
  tags: {
    'file.extension': fileExtension,
  },
})

Comment on lines +1 to +13
const ErrorType = {
UnauthorizedClient: 'unauthorized_client',
AccessDenied: 'access_denied',
UnsupportedResponseType: 'unsupported_response_type',
UnsupportedResponseMode: 'unsupported_response_mode',
InvalidScope: 'invalid_scope',
ServerError: 'server_error',
TemporarilyUnavailable: 'temporarily_unavailable',
InvalidClient: 'invalid_client',
LoginRequired: 'login_required',
InvalidRequest: 'invalid_request',
UserCanceledRequest: 'user_canceled_request',
} as const
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a benefit to using this enum object here? We don't seem to be accessing the value outside of the object definition, could it just be simplified to one object?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're aligning with JavaScript's property naming conventions by receiving snake_case values and converting them to the preferred camelCase format

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I might not have explained myself well, but what I wanted to say is that since we are not actually accessing the enum properties and checking for individual keys inside the getErrorMessage function or anywhere else, there is no need to align this and we can just type it as:

const OktaErrorMappings = { 'server_error': "...", } as const
function getOktaErrorMessage(status){
  return OktaHTTPErrorMappings[status] ?? 'default status'
}

This way we can drop the enum and make keep the definition in a single type as opposed to having to define enum + record to make changes in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I understand your point; the way you listed it is more direct. However, this goes against our ESLint rules and JavaScript's preferred key structure. It will also make more sense if we ever need to access the enum keys, instead of having to refactor it later

Screenshot 2024-09-16 at 10 21 06 AM

Copy link
Contributor

Choose a reason for hiding this comment

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

Ugh more silly linting rules, gonna address these kinda rules a bit more during the GV2 work because they're hampering us more than helping us.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a benefit to having these split out from the component where they're being used? Exporting getErrorMessage by itself may be confusing for others as it's not clear what error messages it's getting, and may be accidentally imported elsewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The object is big and messy. I think it’s cleaner this way. We don’t have a rigid structure for enum files in the codebase, so I don’t think it’s confusing, especially since it’s a file nested within the banner folder

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, they tend to get large and a little messy, and that's alright. If the error messages only relates to Okta and this component specifically, it might make sense to just move the code definitions inside the banner so they are more tightly coupled or rename the export to getOktaErrorMessage.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool I'll rename it to make it even more explicit for its use

@RulaKhaled RulaKhaled added this pull request to the merge queue Sep 16, 2024
Merged via the queue into main with commit 8749dcc Sep 16, 2024
62 checks passed
@RulaKhaled RulaKhaled deleted the okta-banner branch September 16, 2024 15:02
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