Skip to content

No length validation between questions/user_answers/correct_answers #7

Description

@DeFiVC

What

The feedback request model has no cross-validation ensuring len(questions) == len(user_answers) == len(correct_answers):

questions: list[QuizQuestion] = Field(...)
user_answers: list[int] = Field(...)
correct_answers: list[int] = Field(...)

In feedback_engine.py line 44-46, zip(user_answers, correct_answers) silently truncates to the shorter list, causing answers to be silently ignored and incorrect feedback/score computation.

Why

Mismatched list lengths cause silent data loss and incorrect feedback.

Scope

  • Add a Pydantic validator to ensure all three lists have the same length

Acceptance Criteria

  • Requests with mismatched list lengths are rejected
  • Clear error message is provided

Technical Context

  • File: src/routes/feedback.py, lines 20-22
  • Use @model_validator or @validator to cross-validate

Activity

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions