Skip to content

Show an HTML page instead of JSON for missing or invalid report IDs #111

Open

Description

@pablocaeg

Context

Opening /report/doesnotexist in a browser shows raw JSON: {"detail":"Report not found"}. An invalid ID such as /report/abc-123 shows {"detail":"Invalid report ID"}. Reports expire after 30 days, so real users hit this with old links. They should see a normal page with the site header, a short explanation and a link back to the home page.

Where

  • app/routes/web.py, lines 234 and 238: raise HTTPException(...) in report_page().
  • web/templates/base.html: the layout to extend.
  • tests/test_api.py: already checks client.get("/report/abc123").status_code == 404.

What to do

  • In report_page() only (not the /api/... routes, which must keep returning JSON), render a small template such as web/templates/not_found.html instead of raising.
  • Return status 404 for a missing report and 400 for an invalid ID, using templates.TemplateResponse(..., status_code=...).
  • Copy suggestion: "This report does not exist or has expired. Reports are deleted after 30 days." plus a link to /.

Acceptance criteria

  • /report/abc123 returns 404 with text/html and the new page.
  • /report/abc-123 returns 400 with text/html.
  • /api/stream/abc123 still returns JSON.
  • A test in tests/test_api.py checks the status codes and that the body contains the message.

How to test

pip install -r requirements-dev.txt
pytest -q
ruff check app tests scripts
ruff format --check app tests scripts

Setup and conventions: .github/CONTRIBUTING.md. Comment here if you want to take it, and ask anything you are unsure about.

Activity

  1. added
    help wantedExtra attention is needed
    uiThe web UI in web/
    beginnerFriendly for first-time contributors
    on Oct 11, 2026
  2. 8Ashwinee commented on Oct 11, 2026

    @8Ashwinee

    i would like to do this

  3. sloptotal-bot commented on Oct 11, 2026

    @sloptotal-bot

    Welcome, Ashwinee, it's yours. The files are app/routes/web.py (report_page(), around lines 234 and 238), a new web/templates/not_found.html extending web/templates/base.html, and a test in tests/test_api.py next to the existing 404 check. Keep the /api/... routes returning JSON, and use templates.TemplateResponse(..., status_code=...) so the page returns 404 for a missing report and 400 for an invalid ID. Run pytest -q, ruff check app tests scripts and ruff format --check app tests scripts before opening the PR, and put Closes #111 in the description. Ask here if anything in report_page() is unclear. 🙂

    If SlopTotal is useful to you, a ⭐ on the repository helps other people find it.

    Automated reply from the SlopTotal assistant. @pablocaeg reads every thread.

  4. sloptotal-bot commented on Nov 4, 2026

    @sloptotal-bot

    Hi @8Ashwinee, checking in on this one: are you still working on it? No rush, but if you have a draft, opening a pull request (even marked as draft) shows it's in progress.

    If there's no update in 7 days I'll unassign it so someone else can pick it up. You can always ask for it again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

beginnerFriendly for first-time contributorsgood first issueGood for newcomershacktoberfestCounts for Hacktoberfesthelp wantedExtra attention is neededuiThe web UI in web/

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions