{"record":{"id":"38bd3abdc8d756b2","repo":"HKUDS/DeepTutor","slug":"mastery-quiz-options-must-be-an-array-of-non-empty","errorCode":null,"errorMessage":"mastery_quiz.options must be an array of non-empty strings.","messagePattern":"mastery_quiz\\.options must be an array of non-empty strings\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"deeptutor/capabilities/mastery/tools.py","lineNumber":159,"sourceCode":"\n\ndef _normalize_quiz_contract(\n    raw_question_type: Any,\n    raw_options: Any,\n    expected_answer: str,\n) -> tuple[str, list[str], str]:\n    \"\"\"Validate and canonicalise the persisted quiz shape.\n\n    A missing question type is inferred from the actual payload: options mean\n    ``choice`` and no options mean ``short``. Once a caller explicitly chooses\n    ``short`` or ``open``, options are rejected instead of being silently\n    discarded. Choice answers are stored as labels so the interactive card and\n    deterministic grader always compare the same representation.\n    \"\"\"\n    if raw_options is None:\n        options: list[str] = []\n    elif not isinstance(raw_options, list):\n        raise ValueError(\"mastery_quiz.options must be an array of non-empty strings.\")\n    elif any(not isinstance(option, str) or not option.strip() for option in raw_options):\n        raise ValueError(\"mastery_quiz.options must contain only non-empty strings.\")\n    else:\n        options = [option.strip() for option in raw_options]\n\n    supplied_type = str(raw_question_type or \"\").strip().lower()\n    if supplied_type and supplied_type not in _QUESTION_TYPES:\n        allowed = \", \".join(_QUESTION_TYPES)\n        raise ValueError(f\"mastery_quiz.question_type must be one of: {allowed}.\")\n\n    question_type = supplied_type or (\"choice\" if options else \"short\")\n    if question_type != \"choice\":\n        if options:\n            raise ValueError(\n                f\"mastery_quiz.options cannot be used with question_type={question_type!r}; \"\n                \"omit options or use question_type='choice'.\"\n            )\n        return question_type, [], expected_answer","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/capabilities/mastery/tools.py#L141-L177","documentation":"Error \"mastery_quiz.options must be an array of non-empty strings.\" thrown in HKUDS/DeepTutor.","triggerScenarios":"Thrown at deeptutor/capabilities/mastery/tools.py:159 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}