Skip to content

Fix answer missing type error#26

Merged
elvisdragonmao merged 1 commit intomainfrom
fix/fix-answer-missing-type-error
Feb 24, 2026
Merged

Fix answer missing type error#26
elvisdragonmao merged 1 commit intomainfrom
fix/fix-answer-missing-type-error

Conversation

@Kyle9410-Chen
Copy link
Member

Type of changes

  • Fix

Purpose

  • Fix answer missing type error

@elvisdragonmao elvisdragonmao merged commit f74a8af into main Feb 24, 2026
9 checks passed
Copy link
Contributor

Copilot AI left a comment

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 addresses a “missing answer type” error by preventing auto-save from including answers for questions that are not present in the currently visible sections (and therefore not present in the derived questionTypeMap).

Changes:

  • Filter answers during auto-save payload construction to only include answers whose questionId exists in the current sections.
  • Avoid generating update payload entries with an undefined questionType (root cause of the error).
Comments suppressed due to low confidence (1)

src/features/form/components/FormDetailPage.tsx:284

  • answersArray now scans sections for each answer (sections.some(...some...)) even though questionTypeMap is already built from the same sections. You can avoid the extra nested traversal (and make the intent clearer) by filtering on the presence of questionTypeMap[questionId] (or building a Set of valid questionIds once) instead of re-walking sections per entry.
			.filter(([questionId]) => sections.some(section => section.questions?.some(q => q.id === questionId)))
			.filter(([questionId, value]) => value !== "" && !["UPLOAD_FILE", "OAUTH_CONNECT"].includes(questionTypeMap[questionId]))

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

Comment on lines 282 to 285
const answersArray = Object.entries(answers)
.filter(([questionId]) => sections.some(section => section.questions?.some(q => q.id === questionId)))
.filter(([questionId, value]) => value !== "" && !["UPLOAD_FILE", "OAUTH_CONNECT"].includes(questionTypeMap[questionId]))
.map(([questionId, value]) => {
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

This new filter prevents sending answers whose questionType is missing from questionTypeMap (e.g., when a section becomes hidden). However, the submit path (handleSubmit builds answersArray separately later in this file) still constructs payloads from all answers without filtering out questionIds that aren’t in sections/questionTypeMap, so the same “missing type” error can still occur on submit. Consider extracting a shared helper to build the answers payload and reuse it in both auto-save and submit, or apply the same filtering logic in handleSubmit.

Copilot uses AI. Check for mistakes.
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