Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
📦 Next.js Bundle AnalysisThis analysis was generated by the next.js bundle analysis action 🤖 This PR introduced no changes to the javascript bundle 🙌 |
| }); | ||
| const o365AuthCredentials = refreshTokenResponseSchema.parse(await handleErrorsJson(response)); | ||
| const responseJson = await handleErrorsJson(response); | ||
| const tokenResponse = refreshTokenResponseSchema.safeParse(responseJson); |
There was a problem hiding this comment.
Change to safeParse so we don't throw an error if MS sends a response we aren't expecting
| const o365AuthCredentials = refreshTokenResponseSchema.parse(await handleErrorsJson(response)); | ||
| const responseJson = await handleErrorsJson(response); | ||
| const tokenResponse = refreshTokenResponseSchema.safeParse(responseJson); | ||
| o365AuthCredentials = { ...o365AuthCredentials, ...(tokenResponse.success && tokenResponse.data) }; |
There was a problem hiding this comment.
If the responses is what we were expecting, update the new keys. In the spread operator, if keys are present in both objects, the second object's keys will be written
| if (!tokenResponse.success) { | ||
| console.error("zodError:", tokenResponse.error, "MS response:", responseJson); | ||
| } |
There was a problem hiding this comment.
Capture the response on Axiom so we can better diagnose the problem
| refreshTokenResponseSchema.safeParse(o365AuthCredentials).success && | ||
| !isExpired(o365AuthCredentials.expires_in) |
There was a problem hiding this comment.
Refresh the tokens if the keys object is not what we expected or the access token is expired
|
No failed tests 🎉 |
emrysal
left a comment
There was a problem hiding this comment.
Other than that looking good 👍
What does this PR do?
This PR fixes Zod parsing errors in the Outlook auth function. By using safeParse we will not throw an error when the response from MS is not as expected. We also added increased logging of MS error responses to better handle future errors.
Fixes # (issue)
https://www.loom.com/share/3ca4e240e5864151854c50ed88431cc3
Environment: Staging(main branch) / Production
Type of change
How should this be tested?
Checklist