You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
URLs which result in BadRequest errors server side send an overly plain HTML page with "Bad Request" (in production mode) or the stack trace (in dev mode).
As an example, the url path /staging/WNV_NA (which is a bad request because underscores aren't allowed for datasets) looks like so (production nextstrain.org on the left, localhost on the right):
Expected behavior
A page more like that for a valid but non-existing (404) dataset, but with content which communicates that the URL was a bad request, why it was, and (if possible) how one might fix the URL.
Your environment: if browsing Nextstrain online
Nextstrain.org production server running from 24ba9ee
Additional context
The following patch results in Gatsby's 404 page being sent (as seen in the 2nd screenshot above), which is aesthetically an improvement but it changes the client-facing error to 404 and doesn't communicate the error message.
diff --git a/src/routing/errors.js b/src/routing/errors.js
index da31d741..ce4702a0 100644
--- a/src/routing/errors.js+++ b/src/routing/errors.js@@ -2,7 +2,7 @@ import stream from 'stream';
import { promisify } from 'util';
import { PRODUCTION } from '../config.js';
import * as utils from '../utils/index.js';
-import { Forbidden, NotFound, Unauthorized } from '../httpErrors.js';+import { Forbidden, NotFound, BadRequest, Unauthorized } from '../httpErrors.js';
import * as endpoints from '../endpoints/index.js';
import { AuthzDenied } from '../exceptions.js';
@@ -113,7 +113,7 @@ export async function setup(app) {
.end();
}
- if (err instanceof NotFound) {+ if (err instanceof NotFound || err instanceof BadRequest ) {
/* A note about routing: if the current URL path (i.e. req.path) matches a
* a page known to Gatsby (e.g. via the Gatsby page's "path" or "matchPath"
* properties), then Gatsby will perform client-side routing to load that
The text was updated successfully, but these errors were encountered:
As an extension of this issue, and one way to solve it:
We sometimes include helpful information in the various HTTP Errors (server-side), such as
NotFound(`Version descriptor ${versionDescriptor} predates available versions`)
BadRequest(`Requested version must be in YYYY-MM-DD format (version descriptor requested: "${versionDescriptor}")`)
BadRequest(`Resource (e.g. dataset and narrative) paths may not include underscores (_); use slashes (/) instead`);
Were the returned Gatsby page able to access this information (and the corresponding error code) we could then communicate this which would be a nice improvement over the current state.
Current Behavior
URLs which result in
BadRequest
errors server side send an overly plain HTML page with "Bad Request" (in production mode) or the stack trace (in dev mode).As an example, the url path
/staging/WNV_NA
(which is a bad request because underscores aren't allowed for datasets) looks like so (production nextstrain.org on the left, localhost on the right):Expected behavior
A page more like that for a valid but non-existing (404) dataset, but with content which communicates that the URL was a bad request, why it was, and (if possible) how one might fix the URL.
Your environment: if browsing Nextstrain online
Nextstrain.org production server running from 24ba9ee
Additional context
The following patch results in Gatsby's 404 page being sent (as seen in the 2nd screenshot above), which is aesthetically an improvement but it changes the client-facing error to 404 and doesn't communicate the error message.
The text was updated successfully, but these errors were encountered: