From 2bb3bd8fc5acd8da3c5e2ca352f8690477b84879 Mon Sep 17 00:00:00 2001 From: Max Ostapenko <1611259+max-ostapenko@users.noreply.github.com> Date: Sun, 7 Sep 2025 14:40:13 +0200 Subject: [PATCH 1/4] Refactor imports in routes.py and add 404 error handling for tech report pages; update 404.html to simplify messaging --- server/routes.py | 13 ++++++++++--- server/tests/routes_test.py | 28 +++++++++++++++++++++++++++- templates/error/404.html | 6 +----- 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/server/routes.py b/server/routes.py index f89807a4..e9a265c8 100644 --- a/server/routes.py +++ b/server/routes.py @@ -1,11 +1,14 @@ -from flask import redirect, request, jsonify, abort, send_from_directory import re +from flask import abort, jsonify, redirect, request, send_from_directory -from . import app, talisman, render_template, url_for +from . import app +from . import faq as faq_util +from . import render_template from . import reports as report_util +from . import talisman from . import techreport as tech_report_util -from . import faq as faq_util +from . import url_for def safe_int(value, default=1): @@ -88,6 +91,10 @@ def techreportlanding(page_id): # Get the settings for the current page active_tech_report = tech_report.get("pages").get(page_id) + # Check if the page exists + if active_tech_report is None: + abort(404) + # Add the technologies requested in the URL to the filters # Use the default configured techs as fallback # Use ["ALL"] if there is nothing configured diff --git a/server/tests/routes_test.py b/server/tests/routes_test.py index 51c2303d..abf34cc6 100644 --- a/server/tests/routes_test.py +++ b/server/tests/routes_test.py @@ -12,9 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -from server import app, talisman import pytest +from server import app, talisman + # Create test client without https redirect # (normally taken care of by running in debug) @@ -257,6 +258,31 @@ def test_tech_report_category_pages_fallback(client): assert response.status_code == 200 +def test_tech_report_landing_valid_page(client): + response = client.get("/reports/techreport/landing") + assert response.status_code == 200 + + +def test_tech_report_drilldown_page(client): + response = client.get("/reports/techreport/drilldown") + assert response.status_code == 200 + + +def test_tech_report_comparison_page(client): + response = client.get("/reports/techreport/comparison") + assert response.status_code == 200 + + +def test_tech_report_category_page(client): + response = client.get("/reports/techreport/category") + assert response.status_code == 200 + + +def test_tech_report_invalid_page(client): + response = client.get("/reports/techreport/invalid_page_id") + assert response.status_code == 404 + + def test_well_known_atproto_did(client): response = client.get("/.well-known/atproto-did") assert response.status_code == 200 diff --git a/templates/error/404.html b/templates/error/404.html index 73177a38..427421c3 100644 --- a/templates/error/404.html +++ b/templates/error/404.html @@ -4,9 +4,5 @@ {% block error %}Page Not Found{% endblock %} {% block custom %} -

- We've recently launched a new version of the HTTP Archive. - Some URLs may have been updated, please take a look at our new site! - If the information you're looking for is missing, please let us know. -

+

If the information you're looking for is missing, please let us know.

{% endblock %} From 7c9b9f488cb554fb962d108e849b0fa297e9290c Mon Sep 17 00:00:00 2001 From: Max Ostapenko <1611259+max-ostapenko@users.noreply.github.com> Date: Sun, 7 Sep 2025 14:48:21 +0200 Subject: [PATCH 2/4] open gh issue in a new tab --- templates/error/404.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/error/404.html b/templates/error/404.html index 427421c3..ed41867d 100644 --- a/templates/error/404.html +++ b/templates/error/404.html @@ -4,5 +4,5 @@ {% block error %}Page Not Found{% endblock %} {% block custom %} -

If the information you're looking for is missing, please let us know.

+

If the information you're looking for is missing, please let us know.

{% endblock %} From ce3dd03ac50c5d30858beee8f848c2593c9c5116 Mon Sep 17 00:00:00 2001 From: Max Ostapenko <1611259+max-ostapenko@users.noreply.github.com> Date: Sun, 7 Sep 2025 21:08:34 +0200 Subject: [PATCH 3/4] Exclude 404 files from changed files list in lighthouse URL script --- tools/scripts/set_lighthouse_urls.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/scripts/set_lighthouse_urls.sh b/tools/scripts/set_lighthouse_urls.sh index 3e122b6f..db8eed46 100755 --- a/tools/scripts/set_lighthouse_urls.sh +++ b/tools/scripts/set_lighthouse_urls.sh @@ -60,7 +60,7 @@ elif [ "${RUN_TYPE}" == "pull_request" ] && [ "${COMMIT_SHA}" != "" ]; then git pull --quiet git checkout main # Then get the changes - CHANGED_FILES=$(git diff --name-only "main...${COMMIT_SHA}" --diff-filter=d templates config/reports.json | grep -v base.html | grep -v main.html | grep -v ejs | grep -v base_ | grep -v sitemap | grep -v error.html | grep -v techreport/components | grep -v techreport/templates | grep -v techreport/report | grep -v techreport/techreport) + CHANGED_FILES=$(git diff --name-only "main...${COMMIT_SHA}" --diff-filter=d templates config/reports.json | grep -v base.html | grep -v main.html | grep -v ejs | grep -v base_ | grep -v sitemap | grep -v error.html | grep -v techreport/components | grep -v techreport/templates | grep -v techreport/report | grep -v techreport/techreport) | grep -v 404 echo "${CHANGED_FILES}" # Then back to the pull request changes From 5a61af1f848e3cff16adbc32f4007c1862db715b Mon Sep 17 00:00:00 2001 From: Max Ostapenko <1611259+max-ostapenko@users.noreply.github.com> Date: Sun, 7 Sep 2025 21:33:40 +0200 Subject: [PATCH 4/4] fix --- tools/scripts/set_lighthouse_urls.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/scripts/set_lighthouse_urls.sh b/tools/scripts/set_lighthouse_urls.sh index db8eed46..51bb68de 100755 --- a/tools/scripts/set_lighthouse_urls.sh +++ b/tools/scripts/set_lighthouse_urls.sh @@ -60,7 +60,7 @@ elif [ "${RUN_TYPE}" == "pull_request" ] && [ "${COMMIT_SHA}" != "" ]; then git pull --quiet git checkout main # Then get the changes - CHANGED_FILES=$(git diff --name-only "main...${COMMIT_SHA}" --diff-filter=d templates config/reports.json | grep -v base.html | grep -v main.html | grep -v ejs | grep -v base_ | grep -v sitemap | grep -v error.html | grep -v techreport/components | grep -v techreport/templates | grep -v techreport/report | grep -v techreport/techreport) | grep -v 404 + CHANGED_FILES=$(git diff --name-only "main...${COMMIT_SHA}" --diff-filter=d templates config/reports.json | grep -v base.html | grep -v main.html | grep -v ejs | grep -v base_ | grep -v sitemap | grep -v error.html | grep -v techreport/components | grep -v techreport/templates | grep -v techreport/report | grep -v techreport/techreport | grep -v 404) echo "${CHANGED_FILES}" # Then back to the pull request changes