Skip to content
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

feat: Add error pages #13144

Merged
merged 6 commits into from
Mar 4, 2021
Merged

feat: Add error pages #13144

merged 6 commits into from
Mar 4, 2021

Conversation

samtfm
Copy link
Contributor

@samtfm samtfm commented Feb 16, 2021

SUMMARY

Adds custom 404 and 500 error pages as static html

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

404 Screen Shot
500 Screen Shot

TEST PLAN

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

@codecov-io
Copy link

codecov-io commented Feb 16, 2021

Codecov Report

Merging #13144 (3da5007) into master (026782e) will decrease coverage by 4.33%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #13144      +/-   ##
==========================================
- Coverage   77.21%   72.88%   -4.34%     
==========================================
  Files         903      555     -348     
  Lines       45662    20535   -25127     
  Branches     5506     5374     -132     
==========================================
- Hits        35258    14966   -20292     
+ Misses      10278     5441    -4837     
- Partials      126      128       +2     
Flag Coverage Δ
cypress 58.44% <ø> (+0.43%) ⬆️
javascript 62.12% <ø> (-1.29%) ⬇️
mysql ?
postgres ?
python ?
sqlite ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset-frontend/src/dashboard/reducers/types.ts 0.00% <0.00%> (-100.00%) ⬇️
...frontend/src/components/ErrorMessage/IssueCode.tsx 0.00% <0.00%> (-100.00%) ⬇️
...rc/components/ErrorMessage/TimeoutErrorMessage.tsx 0.00% <0.00%> (-100.00%) ⬇️
...c/components/ErrorMessage/DatabaseErrorMessage.tsx 0.00% <0.00%> (-94.74%) ⬇️
.../components/ErrorMessage/ParameterErrorMessage.tsx 6.25% <0.00%> (-90.63%) ⬇️
...rontend/src/components/ErrorMessage/ErrorAlert.tsx 20.40% <0.00%> (-73.47%) ⬇️
...nd/src/components/ErrorMessage/BasicErrorAlert.tsx 35.29% <0.00%> (-64.71%) ⬇️
...onents/ErrorMessage/ErrorMessageWithStackTrace.tsx 27.77% <0.00%> (-50.01%) ⬇️
...ontend/src/dashboard/components/dnd/handleHover.js 88.88% <0.00%> (-11.12%) ⬇️
superset-frontend/src/utils/urlUtils.ts 50.00% <0.00%> (-9.10%) ⬇️
... and 555 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 026782e...577dade. Read the comment docs.

@samtfm samtfm changed the title Add error pages feat: Add error pages Feb 16, 2021
@dpgaspar
Copy link
Member

nit: @samtfm can you add to the description on the PR, that this is just a placeholder, since they are not actually going to get rendered

@etr2460
Copy link
Member

etr2460 commented Feb 16, 2021

Hi @samtfm, thanks for the contribution! I'm wondering if you could speak a bit about the architecture approach you chose here.

Most of the frontend assets in Superset are rendered using React, and those that don't we're quickly trying to replace (like the HTML templates that flask renders). Why was the decision made to use raw HTML and CSS for these pages instead of making use of the shared React components and React render logic already available in the app?

@willbarrett
Copy link
Member

Hi @etr2460 the goal from Preset's side is to add static error pages that can be rendered directly from a web server (such as nginx) without relying on the rest of the systems. We thought they might be nice to contribute back to the community for others who have the same need. Happy to make that more obvious however it would be most useful.

@etr2460
Copy link
Member

etr2460 commented Feb 16, 2021

Thanks for the context @willbarrett! Adding this to the PR summary would definitely be helpful (especially since they're not used anywhere in code, and therefore might get deleted as unused code in the future without that documentation).

Also, for this use case, I wonder if the CSS (and even images with base64) should be embedded within the html files to prevent further dependencies.

@willbarrett
Copy link
Member

Yes, I think that's a good idea @etr2460 - a little duplication would make them easier to deploy. If we find we need more than two, it might be possible to create a simple static page generator to spit them out, but I think we should wait for a request for a 3rd error page before going down that path.

@willbarrett
Copy link
Member

Perhaps we can add a README to the static-pages folder to explain the presence of these HTML files.

@samtfm
Copy link
Contributor Author

samtfm commented Feb 16, 2021

Thanks all. Copying the css into the two files sounds good. I'd also propose I move the referenced image files into this static-pages directory.

I'm a little wary of the legibility of embedding images as base64 if these aren't going to be auto-generated, but I suppose I could still include the source files in the same folder, and include the steps for updating the html in the README.

@ktmud
Copy link
Member

ktmud commented Feb 16, 2021

Maybe you can take advantage of the html-webpack-plugin to build a static error pages with all styles and images embedded?

I'm also wondering whether it makes sense to let Python/Jinja render 404 and 403 first, and only fallback to a static 500 page in Nginx if the Python render fails. So you can do more advanced stuff with these error pages like having global navs and render more customized error messages, etc

@samtfm
Copy link
Contributor Author

samtfm commented Feb 19, 2021

@ktmud thank you for the suggestion! I've refactored this using html-webpack-plugin to render these html files directly to the distribution folder.
I'm leaving the css hard coded into each html file for now, because fully embedding it from a separate file would require even more complications to the webpack config, and I think this is fine enough for now with just these two pages.

(package-lock.json got updated in a big way that I didn't intend, I am currently looking into how to tell npm to add a package without doing this lockfileVersion update)

@ktmud
Copy link
Member

ktmud commented Feb 19, 2021

@samtfm Did you use npm 7? We recently upgrade lockfileversion 2 but you need to use npm 7: #13100

@samtfm samtfm force-pushed the add-error-pages branch 4 times, most recently from 453fef2 to 8cfc4ec Compare February 20, 2021 00:15
Copy link
Member

@willbarrett willbarrett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once rebased.

@samtfm samtfm force-pushed the add-error-pages branch from 8cfc4ec to 577dade Compare March 3, 2021 22:38
@willbarrett willbarrett merged commit 0318b6d into apache:master Mar 4, 2021
@samtfm samtfm deleted the add-error-pages branch March 30, 2021 21:14
allanco91 pushed a commit to allanco91/superset that referenced this pull request May 21, 2021
* add custom error pages for 404 and 500 responses

* refactor error page styles into separate template

* move error pages to superset-frontend

* fix whitespace on error pages

* refactor error pages to be generated by jinja

* generate static error pages with webpack
@mistercrunch mistercrunch added the 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels label Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels preset-io 🚢 1.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants