Skip to content

fix(submissions): fix unhandled 404s in assessment/submission routes - #8552

Merged
adi-herwana-nus merged 1 commit into
masterfrom
adi/submission-edit-url-fixes
Aug 18, 2026
Merged

fix(submissions): fix unhandled 404s in assessment/submission routes#8552
adi-herwana-nus merged 1 commit into
masterfrom
adi/submission-edit-url-fixes

Conversation

@adi-herwana-nus

Copy link
Copy Markdown
Contributor

Problem

Two dead ends in the submission and assessment routes:

/submissions/:id rendered a blank page. The :submissionId route has children but no element
of its own. React Router still creates a match branch for a parent route, so an exact
/submissions/5 matched it and rendered a default <Outlet /> with nothing inside — it never fell
through to the not-found route.

A submission or assessment ID that doesn't exist showed no 404. The backend returns 404, but the
frontend swallowed it:

Page Fetch What the user saw
Attempt (submissions/:id/edit) fetchSubmission Blank page — the catch only flipped isLoading off, leaving the page to render against an empty store
Assessment (assessments/:id) fetchAssessment via Preload Generic red "fetching error" note and toast
Access logs (submissions/:id/logs) fetchLogs via Preload Same generic error note

The existing response interceptor only redirects on the 404 whose body says "component not found"
(a disabled course component). A missing record raises ActiveRecord::RecordNotFound, whose response
doesn't match, so nothing redirected.

Change

An index route under :submissionId redirects to edit, matching the pattern already used for
marketplace/listings.

A redirectToNotFoundIfMissing helper in api/ErrorHandling.ts redirects to the not-found page on a
404 and returns whether it did, so callers can skip their own error handling. It is applied at the
three fetches above.

Note this covers more than a typo'd ID. Resources are loaded through their parent — through: :course
in Course::Assessment::Controller, through: :assessment in
Course::Assessment::Submission::Controller — so CanCanCan scopes the find to
@course.assessments / @assessment.submissions. An assessment that exists in another course
raises RecordNotFound before authorization ever runs, and so 404s rather than 403s. That is the
right split, and it means the not-found path leaks no existence information across courses.

Why the helper is opt-in

The obvious alternative is to redirect on every 404 inside redirectIfMatchesErrorIn, in the
response interceptor. That would break callers that treat a 404 as a normal outcome — sendOldSessions
in the video submission actions uses it to detect a session the backend has already dropped. Keeping
it opt-in also leaves the existing local handling in RubricPlaygroundPage coherent.

Preload's own onErrorDo was not usable for the two Preload pages: it receives
error.response?.data, not the status, so the check has to sit at the call site.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves UX and correctness for invalid/missing assessment/submission routes by ensuring they redirect to the Not Found page (instead of rendering blank pages or generic fetch errors), and by adding an index redirect for the /submissions/:id parent route.

Changes:

  • Add an index route under :submissionId that redirects /submissions/:id to /submissions/:id/edit.
  • Introduce redirectToNotFoundIfMissing to opt-in redirect-to-404 behavior for missing-record 404s.
  • Apply the helper to submission attempt, assessment show, and submission logs fetch paths to avoid “blank page” / generic error states.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
client/app/routers/course/assessments/submissions.tsx Adds an index redirect under :submissionId to avoid rendering an empty outlet.
client/app/bundles/course/assessment/submission/actions/logs.ts Redirects missing submission-log requests to Not Found when backend returns 404.
client/app/bundles/course/assessment/submission/actions/index.js Redirects missing submission attempts to Not Found on 404 instead of leaving an empty page state.
client/app/bundles/course/assessment/pages/AssessmentShow/index.tsx Redirects missing assessments to Not Found rather than showing Preload’s generic fetch error UI.
client/app/api/ErrorHandling.ts Adds an opt-in helper to redirect on missing-record 404 responses.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread client/app/bundles/course/assessment/pages/AssessmentShow/index.tsx
Comment thread client/app/bundles/course/assessment/submission/actions/logs.ts
@adi-herwana-nus
adi-herwana-nus merged commit 6a98b34 into master Aug 18, 2026
15 checks passed
@adi-herwana-nus
adi-herwana-nus deleted the adi/submission-edit-url-fixes branch August 18, 2026 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants