-
Notifications
You must be signed in to change notification settings - Fork 44
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
refactor: Update Error handling for Identity API Client #959
base: refactor/ts-migration-blackout-2024
Are you sure you want to change the base?
refactor: Update Error handling for Identity API Client #959
Conversation
src/identityApiClient.ts
Outdated
case HTTP_OK: | ||
case HTTP_ACCEPTED: | ||
message = 'Received Identity Response from server: '; | ||
message += JSON.stringify(identityResponse.responseText); | ||
break; | ||
|
||
default: { | ||
// 400 has an error message, but 403 doesn't | ||
const errorResponse: IdentityApiErrorResponse = identityResponse.responseText as unknown as IdentityApiErrorResponse; | ||
if (errorResponse?.Errors) { | ||
message = 'Issue with sending Identity Request to mParticle Servers, received HTTP Code of ' + identityResponse.status; | ||
|
||
const errorMessage = errorResponse.Errors.map((error) => error.message).join(', '); | ||
message += ' - ' + errorMessage; | ||
} | ||
} | ||
} | ||
|
||
verbose(message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you write a test that accounts for the message being passed through, since this is new behavior?
Quality Gate failedFailed conditions |
|
||
break; | ||
|
||
// 401 and 403 have no bodies and should be rejected outright |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: Add specific comments as to what will cause a 401 or 403
case HTTP_ACCEPTED: | ||
case HTTP_OK: | ||
|
||
// 400 error will has a body and will go through the happy path to report the error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: Add context to what would cause a 400
|
||
break; | ||
|
||
// 401 and 403 have no bodies and should be rejected outright |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: Rephrase to say 'All other error codes will hit this path'
Instructions
development
Summary
Testing Plan
Reference Issue (For mParticle employees only. Ignore if you are an outside contributor)