srbhr/Resume-Matcher · error · ValueError

answer text must not be blank

Error message

answer text must not be blank

What it means

ResumeWizardHistoryEntry.text is a required string of 1-6000 chars, and the _reject_blank field_validator additionally rejects values that are only whitespace. A whitespace-only answer (e.g. " ") passes min_length but fails the strip() check, raising this ValueError during validation.

Source

Thrown at apps/backend/app/schemas/resume_wizard.py:49


class ResumeWizardProgress(BaseModel):
    """Server-computed progress for the question card's bar."""

    current: int = 0
    total: int = 8


class ResumeWizardAnswer(BaseModel):
    """User answer for one wizard turn."""

    text: str = Field(min_length=1, max_length=6000)

    @field_validator("text")
    @classmethod
    def _reject_blank(cls, value: str) -> str:
        if not value.strip():
            raise ValueError("answer text must not be blank")
        return value


class ResumeWizardHistoryEntry(BaseModel):
    """One answered question, with a pre-answer draft snapshot for Back."""

    question: str
    answer: str
    section: ResumeWizardSection
    resume_data_before: ResumeData


class ResumeWizardState(BaseModel):
    """Complete state that round-trips between client and server."""

    step: ResumeWizardStep = "intro"
    resume_data: ResumeData = Field(default_factory=ResumeData)
    current_question: ResumeWizardQuestion = Field(default_factory=ResumeWizardQuestion)

View on GitHub (pinned to 116f9cc3b0)

Solutions

  1. Ensure the caller sends non-whitespace answer text before constructing the model
  2. Add an application-level check: if not answer.strip(): reject/reprompt the user
  3. If the field may be legitimately absent, make it Optional instead of blank
  4. Strip and re-check user input at the API boundary before deserialization

Example fix

// before
ResumeWizardHistoryEntry(text="   ", ...)
// after
text = answer.strip()
if not text:
    raise HTTPException(422, "answer text must not be blank")
ResumeWizardHistoryEntry(text=text, ...)
Defensive patterns

Strategy: validation

Validate before calling

def answer_is_valid(t: str) -> bool:
    return isinstance(t, str) and 1 <= len(t) <= 6000 and bool(t.strip())

Type guard

def is_nonblank_str(v: object) -> TypeGuard[str]:
    return isinstance(v, str) and v.strip() != ""

Try / catch

try:
    entry = ResumeWizardHistoryEntry.model_validate(payload)
except ValidationError as e:
    raise HTTPException(422, "answer text must not be blank") from e

Prevention

When it happens

Trigger: Creating or validating a ResumeWizardHistoryEntry with text set to "", " ", "\n", "\t", or any string whose strip() is empty.

Common situations: Frontend sends an empty answer after the user hits enter on a blank field; upstream text extraction trims content to whitespace; test fixtures with placeholder blanks.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of srbhr/Resume-Matcher@116f9cc3b0 (2026-08-28). Data as JSON: /api/errors/3da9b52826d89934. Report an issue: GitHub.