srbhr/Resume-Matcher · error · ValueError
answer is required for answer actions
Error message
answer is required for answer actions
What it means
ResumeWizardTurnRequest's model validator _validate_answer_present requires the 'answer' field to be populated when action == 'answer'. Since answer defaults to None, sending an answer action without an answer payload raises this ValueError at validation time.
Source
Thrown at apps/backend/app/schemas/resume_wizard.py:86
history: list[ResumeWizardHistoryEntry] = Field(default_factory=list)
asked_count: int = 0
inferred_skills: list[str] = Field(default_factory=list)
is_complete: bool = False
progress: ResumeWizardProgress = Field(default_factory=ResumeWizardProgress)
warnings: list[str] = Field(default_factory=list)
class ResumeWizardTurnRequest(BaseModel):
"""Request for one wizard turn."""
state: ResumeWizardState
action: ResumeWizardAction
answer: ResumeWizardAnswer | None = None
@model_validator(mode="after")
def _validate_answer_present(self) -> "ResumeWizardTurnRequest":
if self.action == "answer" and self.answer is None:
raise ValueError("answer is required for answer actions")
return self
class ResumeWizardTurnResponse(BaseModel):
"""Response for one wizard turn."""
state: ResumeWizardState
class ResumeWizardFinalizeRequest(BaseModel):
"""Request to create the master resume from the wizard draft."""
state: ResumeWizardState
@model_validator(mode="after")
def _validate_ready_to_finalize(self) -> "ResumeWizardFinalizeRequest":
if not self.state.resume_data.personalInfo.name.strip():
raise ValueError("personalInfo.name is required")View on GitHub (pinned to 116f9cc3b0)
Solutions
- Include a valid ResumeWizardAnswer object when action is "answer"
- If the user has no answer, use the appropriate action (e.g. "skip") instead
- Validate on the client before submitting that the answer is present for answer actions
- Return a 422 with this message so the client can recover
Example fix
// before ResumeWizardTurnRequest(action="answer") // after ResumeWizardTurnRequest(action="answer", answer=ResumeWizardAnswer(text="My answer"))
Defensive patterns
Strategy: validation
Validate before calling
def turn_request_ok(r: dict) -> bool:
return r.get("action") != "answer" or r.get("answer") is not None Type guard
def has_answer(r: ResumeWizardTurnRequest) -> bool:
return r.answer is not None Try / catch
try:
req = ResumeWizardTurnRequest.model_validate(body)
except ValidationError as e:
raise HTTPException(422, "answer is required for answer actions") from e Prevention
- Keep answer collection and action selection in sync in the wizard UI
- Default non-answer actions (skip/done) when no answer text exists
- Add a client-side pre-submit check tying action to answer presence
When it happens
Trigger: POSTing a ResumeWizardTurnRequest with action="answer" and answer omitted or explicitly null.
Common situations: Frontend wizard state machine advances to the answer turn but forgets to attach the collected answer; API consumers testing with minimal payloads; skip/answer action confusion.
Understand the failure class
Background: "Missing required field" and "field is required" errors: why libraries reject payloads that omit mandatory fields — this error's family across 20 libraries.
Related errors
- personalInfo.name is required
- 'original' may be a list only for the reorder action
- answer text must not be blank
- ${message = data.detail or Failed to update LLM config (stat
- ${data.detail || Failed to update feature config (status ${r
AI-assisted analysis of srbhr/Resume-Matcher@116f9cc3b0 (2026-08-28).
Data as JSON: /api/errors/5b57dddb38825df9.
Report an issue: GitHub.