HKUDS/DeepTutor · error · ValueError

mastery_quiz.options must contain only non-empty strings.

Error message

mastery_quiz.options must contain only non-empty strings.

What it means

Error "mastery_quiz.options must contain only non-empty strings." thrown in HKUDS/DeepTutor.

Source

Thrown at deeptutor/capabilities/mastery/tools.py:161

def _normalize_quiz_contract(
    raw_question_type: Any,
    raw_options: Any,
    expected_answer: str,
) -> tuple[str, list[str], str]:
    """Validate and canonicalise the persisted quiz shape.

    A missing question type is inferred from the actual payload: options mean
    ``choice`` and no options mean ``short``. Once a caller explicitly chooses
    ``short`` or ``open``, options are rejected instead of being silently
    discarded. Choice answers are stored as labels so the interactive card and
    deterministic grader always compare the same representation.
    """
    if raw_options is None:
        options: list[str] = []
    elif not isinstance(raw_options, list):
        raise ValueError("mastery_quiz.options must be an array of non-empty strings.")
    elif any(not isinstance(option, str) or not option.strip() for option in raw_options):
        raise ValueError("mastery_quiz.options must contain only non-empty strings.")
    else:
        options = [option.strip() for option in raw_options]

    supplied_type = str(raw_question_type or "").strip().lower()
    if supplied_type and supplied_type not in _QUESTION_TYPES:
        allowed = ", ".join(_QUESTION_TYPES)
        raise ValueError(f"mastery_quiz.question_type must be one of: {allowed}.")

    question_type = supplied_type or ("choice" if options else "short")
    if question_type != "choice":
        if options:
            raise ValueError(
                f"mastery_quiz.options cannot be used with question_type={question_type!r}; "
                "omit options or use question_type='choice'."
            )
        return question_type, [], expected_answer

    intended_labels = option_label_intent(options)

View on GitHub (pinned to 3e82f13042)

When it happens

Trigger: Thrown at deeptutor/capabilities/mastery/tools.py:161 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27). Data as JSON: /api/errors/e51aeba1ad3db18e. Report an issue: GitHub.