Skip to content

Fix crash on advancing to lower-option question in quiz - #173

Merged
bitbacchus merged 2 commits into
mainfrom
fix/answers-length-render-crash
Aug 26, 2026
Merged

Fix crash on advancing to lower-option question in quiz#173
bitbacchus merged 2 commits into
mainfrom
fix/answers-length-render-crash

Conversation

@bitbacchus

Copy link
Copy Markdown
Member

Advancing from a higher-option question to a lower-option one threw "undefined is not an object (question.answers[i].correct)" during render (react-router's error screen since the RR7 upgrade). The answers reset moved from the synchronous submit handler into useEffect([run.counter]) (47bef5d/2f38b35, quiz-counter family), so stale answers — sized to the previous, larger question — survived one render past the counter change and isMultiChoiceAnsweredCorrectly indexed question.answers out of bounds.

Two layers, neither reintroducing the synchronous reset removed in 47bef5d (which reopens the repetition-glitch double submission):

  • Guard isMultiChoiceAnsweredCorrectly: return false when the selection is longer than the current question's options instead of indexing OOB.
  • Reset per-question local state during render on questionId change, so it fires in step with currentQuestion (only after the counter round-trip).

Add src/utils.test.ts covering the regression. Bump frontend 1.7.1 -> 1.7.2, add NEWS.md v1.7.2 entry.

…uestion

Advancing from a higher-option question to a lower-option one threw
"undefined is not an object (question.answers[i].correct)" during render
(react-router's error screen since the RR7 upgrade). The `answers` reset
moved from the synchronous submit handler into useEffect([run.counter])
(47bef5d/2f38b35, quiz-counter family), so stale `answers` — sized to the
previous, larger question — survived one render past the counter change and
isMultiChoiceAnsweredCorrectly indexed question.answers out of bounds.

Two layers, neither reintroducing the synchronous reset removed in 47bef5d
(which reopens the repetition-glitch double submission):
- Guard isMultiChoiceAnsweredCorrectly: return false when the selection is
  longer than the current question's options instead of indexing OOB.
- Reset per-question local state during render on questionId change, so it
  fires in step with currentQuestion (only after the counter round-trip).

Add src/utils.test.ts covering the regression. Bump frontend 1.7.1 -> 1.7.2,
add NEWS.md v1.7.2 entry.
@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

… upload

Add a RunningQuizTab render test that selects an option on a 4-option question
then advances to a 2-option one, reproducing the answers-length render crash and
covering both the in-render questionId reset and the utils guard.

Make codecov-action upload the per-package lcov reports explicitly with
fail_ci_if_error, so a missing frontend report surfaces instead of showing up as
0% patch coverage.

Two notes:
- fail_ci_if_error: true means a genuine Codecov outage will now fail CI — the right trade for reliable coverage gating, but worth knowing.
- After you push, check the Codecov comment: if it's still 0%, the report genuinely isn't being ingested and we'd dig into the upload step (flags/token); if it jumps to ~100%, both issues are resolved. My money's on resolved.
@bitbacchus
bitbacchus merged commit 11c7861 into main Aug 26, 2026
6 checks passed
@bitbacchus
bitbacchus deleted the fix/answers-length-render-crash branch August 26, 2026 15:31
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.

1 participant