{"record":{"id":"0c635d61801917dd","repo":"langchain-ai/deepagents","slug":"choice-has-a-blank-value-choice-r","errorCode":null,"errorMessage":"choice has a blank 'value': {choice!r}","messagePattern":"choice has a blank 'value': (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/_ask_user_types.py","lineNumber":213,"sourceCode":"    itself, so `TypeAdapter(Choice)` does not apply it.\n\n    Callers must pass a parsed `Choice`. A missing `value` never reaches here —\n    it is a required key, so pydantic rejects it as `choices.N.value: Field\n    required` before the choice-level validators run. On a raw dict this would\n    raise `KeyError`, which is not a `ValidationError` and would halt the run.\n\n    Args:\n        choice: The parsed `Choice` to check.\n\n    Returns:\n        The same `choice`, unchanged.\n\n    Raises:\n        ValueError: If `value` is blank or whitespace-only.\n    \"\"\"\n    if not choice[\"value\"].strip():\n        msg = f\"choice has a blank 'value': {choice!r}\"\n        raise ValueError(msg)\n    return choice\n\n\nclass Choice(TypedDict):\n    \"\"\"A single choice option for a multiple choice or multi-select question.\"\"\"\n\n    value: Annotated[\n        str,\n        Field(\n            description=(\n                \"The display label for this choice. Also the text returned as \"\n                \"the answer when this choice is selected. A 'multi_select' answer \"\n                \"is a JSON array, so a value may contain commas, quotes, and \"\n                \"newlines; JSON escaping keeps it exact. A 'multiple_choice' \"\n                \"value is returned on its own with no escaping, so keep that \"\n                \"one to a single line.\"\n            )\n        ),","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/_ask_user_types.py#L195-L231","documentation":"`_validate_choice` raises ValueError when a Choice's `value` key is empty or whitespace-only. The `value` is the machine-readable answer returned to the agent, so it must be non-blank; the optional `label` is what the user sees.","triggerScenarios":"An ask_user question containing a choice like `{\"value\": \"\", \"label\": \"Yes\"}` or `{\"value\": \"   \"}` — validation runs in `_validate_choice` at libs/code/deepagents_code/_ask_user_types.py:213.","commonSituations":"An LLM emitting choices with placeholder/empty values; code that strips display labels but forgets values; generating choices from a source list containing empty strings; copying a choice template without filling `value`.","solutions":["Give every choice a non-empty, distinct `value` string (e.g. \"yes\", \"postgres\")","Put the human-friendly wording in `label` and keep `value` as a short identifier","Sanitize generated choices by filtering out entries whose value strips to empty before submitting the question","If values derive from user data, trim and de-duplicate them before building the Choice"],"exampleFix":"# before\n{\"value\": \"\", \"label\": \"PostgreSQL\"}\n# after\n{\"value\": \"postgres\", \"label\": \"PostgreSQL\"}","handlingStrategy":"validation","validationCode":"for c in choices:\n    if not c.get(\"value\", \"\").strip():\n        raise ValueError(f\"choice has a blank 'value': {c!r}\")","typeGuard":"def is_valid_choice(c: dict) -> bool:\n    return isinstance(c.get(\"value\"), str) and bool(c[\"value\"].strip())","tryCatchPattern":"try:\n    ask_user(questions=questions)\nexcept ValueError as exc:\n    if \"blank 'value'\" in str(exc):\n        # regenerate or filter choices before retrying\n        ...\n    else:\n        raise","preventionTips":["Give every choice a short non-empty machine-readable `value`; put display text in `label`","Sanitize model-generated choices: trim values and drop empties before submitting","De-duplicate values so choices are distinguishable","Unit-test question builders with edge inputs (empty strings, whitespace-only values)"],"tags":["validation","ask-user","dcode","valueerror","choices"],"backgroundTag":"schema-validation-failed","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}