-
Notifications
You must be signed in to change notification settings - Fork 16
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
[Issue #3152] properly error on client for max search term length #3554
Conversation
e206b3f
to
a2d503d
Compare
const ErrorAlert = | ||
parsedErrorData.details && parsedErrorData.type === "ValidationError" ? ( | ||
<Alert type="error" heading={t("validationError")} headingLevel="h4"> | ||
{`Error in ${parsedErrorData.details.field || "a search field"}: ${parsedErrorData.details.message || "adjust your search and try again"}`} |
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.
Could we do a follow-up to translate this, ie the "adjust your search and try again"?
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 can make a ticket, but I'm not exactly sure what the scope would need to be. To get this to work as a fully translated UI we'd need to handle translating stuff that's coming from the API, including error messages and our field names. That seems to open up a lot of questions, and since it doesn't seem like we're prioritizing translation right now I don't know when the right time for that conversation is
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 meant the a search field
part.
frontend/src/errors.ts
Outdated
*/ | ||
|
||
import { QueryParamData } from "src/types/search/searchRequestTypes"; | ||
|
||
export interface FrontendErrorDetails { |
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.
Is there a reason not to store this in src/types/...
?
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.
👍🏿 with a few nit Qs
…earch validation error
5960572
to
3d0dc4e
Compare
Summary
Fixes #3152
Time to review: 20 mins
Changes proposed
Main goal here is to show a helpful error message with a relevant call to action to users when they enter a search term longer than the API allows (100 characters).
To do that this change:
This change also fixes a bug that was preventing the search form state to be maintained in the case of an error.
I also observed when doing this work that Next seems to treat the errors thrown by the search fetcher to be unhandled, even though they redirect to the search error page. This means the error toast thing shows up on dev, and the error is logged to the console as unhandled. Is this expected?
Context for reviewers
Test steps for client side validation
npm run dev
Test steps for error response handling
Totally synthetic but the easiest way to do this is to disable the client side check.
Additional information
Server side error
Client side validation error