Skip to content

fix: Survey crash caused by fully answered survey#1273

Merged
mariush2 merged 2 commits into
mainfrom
fix/survey-question-index
Apr 28, 2026
Merged

fix: Survey crash caused by fully answered survey#1273
mariush2 merged 2 commits into
mainfrom
fix/survey-question-index

Conversation

@mariush2

Copy link
Copy Markdown
Contributor
  • Needs to be tested locally by reviewer

Description

If a survey's questions were all answered (which shouldn't really happen, but backend is sending answered surveys atm) the survey provider would cause a crash because activeQuestionIndex was being set to -1

Copilot AI review requested due to automatic review settings April 27, 2026 06:14
@mariush2 mariush2 requested a review from a team as a code owner April 27, 2026 06:14
@mariush2 mariush2 requested a review from arkadiy93 April 27, 2026 06:14

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

Fixes a crash in the SurveyProvider when the backend returns a survey where all questions are already answered, which previously resulted in activeQuestionIndex being set to -1 and downstream indexing errors.

Changes:

  • Clamp the initially computed question index to 0 when no unanswered question is found.
  • Add tests covering “all answered” and “some answered” initialization cases.
  • Bump package version from 12.0.3 to 12.0.4.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/providers/SurveyProvider/SurveyProvider.tsx Prevents activeQuestionIndex from being initialized to -1 when all questions are answered.
src/providers/SurveyProvider/SurveyProvider.test.tsx Adds regression coverage for the initialization behavior with answered/unanswered question sets.
package.json Patch version bump for the fix release.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/providers/SurveyProvider/SurveyProvider.test.tsx
@github-actions

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 100% (🎯 100%) 17253 / 17253
🔵 Statements 100% (🎯 100%) 17253 / 17253
🔵 Functions 100% (🎯 100%) 1240 / 1240
🔵 Branches 100% (🎯 100%) 4368 / 4368
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/providers/SurveyProvider/SurveyProvider.tsx 100% 100% 100% 100%
Generated in workflow #2245 for commit 0c6e709 by the Vitest Coverage Report Action

@arkadiy93 arkadiy93 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.

LGTM ✔️

@mariush2 mariush2 merged commit ac8a214 into main Apr 28, 2026
15 checks passed
@mariush2 mariush2 deleted the fix/survey-question-index branch April 28, 2026 05:58
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.

3 participants