-
Notifications
You must be signed in to change notification settings - Fork 129
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
[10-10CG] Reset csrfToken on 403 response for fetchFacilities #34431
[10-10CG] Reset csrfToken on 403 response for fetchFacilities #34431
Conversation
…est returns a 403 Invalid Authenticity Token response
@@ -125,10 +125,27 @@ export const fetchFacilities = async ({ | |||
}) | |||
.catch(error => { | |||
Sentry.withScope(scope => { | |||
scope.setExtra('error', error); | |||
scope.setExtra('error', error.errors); |
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.
This errors object was just showing
{
errors: [
[Object]
]
}
Which is not helpful. This will instead show the error array which has more detail.
|
||
if ( | ||
errorResponse?.status === '403' && | ||
errorResponse?.detail === 'Invalid Authenticity Token' |
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.
I only want to trigger this for 403s AND when it is an Invalid Authenticity Token
, since there are other valid 403 responses we don't want to trigger this logic.
scope.setExtra('status', errorResponse?.status); | ||
scope.setExtra('detail', errorResponse?.detail); | ||
Sentry.captureMessage( | ||
'Error in fetchFacilities. Clearing csrfToken in localStorage.', |
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.
Added new Sentry log so we know when these occur and give us more detail into what's going on.
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.
Sentry call found
Sentry captures a lot of data, and we want to make sure that we only keep information that will be useful for troubleshooting issues. This means that PII should not be recorded.
What you can do
Review your call to Sentry and see if you can reasonably reduce any information that is included, or wait for a VSP review.
Are you removing, renaming or moving a folder in this PR?
If the folder you changed contains a
manifest.json
, search for itsentryName
in the content-build registry.json (theentryName
there will match).If an entry for this folder exists in content-build and you are:
Deleting a folder:
vets-website
for all instances of theentryName
in yourmanifest.json
and remove them in a separate PR. Look particularly for references insrc/applications/static-pages/static-pages-entry.js
andsrc/platform/forms/constants.js
. If you do not do this, other applications will break!Renaming or moving a folder: Update the entry in the registry.json, but do not merge it until your vets-website changes here are merged. The content-build PR must be merged immediately after your vets-website change is merged in to avoid CI errors with content-build (and Tugboat).
Examples of a TeamSite: https://va.gov/health and https://benefits.va.gov/benefits/. This scenario is also referred to as the "injected" header and footer. You can reach out in the
#sitewide-public-websites
Slack channel for questions.Did you change site-wide styles, platform utilities or other infrastructure?
Summary
Invalid Authenticity Token
in our new facilities search page. The last two appear to have tried to pass invalid csrf tokens from the client.403 - Invalid Authenticity Token
error we set thecsrfToken
in localStorage to an empty string. If the request is retried, it will trigger the logic that checks if there is a token, and if not it makes aHEAD
request to ensure it has a valid token, which then calls thefetchFacilities
with a valid token.caregiver_use_facilities_API
toggleRelated issue(s)
Testing done
Screenshots
No UI changes
What areas of the site does it impact?
10-10CG
Acceptance criteria
Quality Assurance & Testing
Error Handling
Authentication