8000 API routes can answer with an HTML error page; AppError keeps two variants of everything · Issue #300 · alexbeeken/skrongle-mini · GitHub
[go: up one dir, main page]

Skip to content
< 7FFF div data-color-mode="dark" data-light-theme="light" data-dark-theme="dark">

API routes can answer with an HTML error page; AppError keeps two variants of everything #300

Backlog

Description

@alexbeeken

AppError has six page/API pairs: BadRequest/ApiBadRequest, RedirectToLogin/Unauthorized, RedirectToCourses/ApiNoCourse, PasswordChangeRequired/Api…, AiOff/ApiAiOff, NoPermission/ApiNoPermission. CurrentUser mirrors them with require_* and require_*_api. Extractors choose by path.starts_with("/api/"); handlers choose by hand.

NotFound, Db and Internal have no API form, so these answer a script with an HTML page: pages::save_note (POST /api/lessons/{slug}/note), tutor::session (GET /api/tutor/session), manage::save_keys, and any database error on any /api/* route.

Fix, one PR: into_response records the kind of error in a response extension. error::in_layout, which already works out whether the request is an API one, draws {"error": …} or the page. Then the six Api* variants and the _api methods go.

Related, same PR or the next:

  • API error text is mixed: 44 ApiBadRequest(crate::t(…)) against 23 English literals such as "implausible result" and "unknown lesson" (routes/sprint.rs, routes/guide.rs).
  • A refused form answers 200 (src/routes/profile.rs:501), 403 (two-factor), 422 (token and code forms) or a redirect with a notice (courses). prove_owner returns (StatusCode, String) and callers branch on the status to pick a message. A ProofRefused enum and one status for "show the form again".

From the code review of 24 November 2026. Line numbers are as of 0.5.0 (2547b36).

Activity

  1. added
    review
    on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    review

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0