HKUDS/DeepTutor · error · RuntimeError

Failed to extract questions from parsed exam

Error message

Failed to extract questions from parsed exam

What it means

Raised by _parse_sync in the question-mimic pipeline when the parsed exam document yields no *_questions.json output — the extraction stage ran (or was skipped) but produced no question JSON in questions_dir. Indicates the parse produced no extractable question structures for this paper.

Solutions

  1. Check that the document parsed successfully (doc.workdir populated, parse artifacts present)
  2. Inspect extraction logs for the paper; try a different parsing engine in Settings → Document Parsing
  3. Verify the paper is a supported exam format; OCR quality may be too low for extraction
  4. Confirm questions_dir/output_base is writable and the glob pattern matches the extractor's naming
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at deeptutor/agents/question/mimic_source.py:122 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/b6e3054d83bc5668. Report an issue: GitHub.

Appendix: source

Thrown at deeptutor/agents/question/mimic_source.py:122

        working_dir = paper_path
        questions_dir = working_dir
    else:
        # Shared parse layer: cached + engine-pluggable (the active engine is
        # selected in Settings → Document Parsing). Returns the cache dir with
        # the parsed artifacts; the questions JSON goes to the session output
        # dir so it never pollutes the shared parse cache.
        doc = get_parse_service().parse(paper_path, on_output=progress_callback)
        working_dir = doc.workdir or paper_path
        questions_dir = output_base

    json_files = list(questions_dir.glob("*_questions.json"))
    if not json_files:
        ok = extract_questions_from_paper(
            str(working_dir),
            output_dir=None if questions_dir == working_dir else str(questions_dir),
        )
        if not ok:
            raise RuntimeError("Failed to extract questions from parsed exam")
        json_files = list(questions_dir.glob("*_questions.json"))
    if not json_files:
        raise RuntimeError("Question extraction output not found")

    with json_files[0].open(encoding="utf-8") as fh:
        payload = json.load(fh)
    questions = payload.get("questions") or []
    if max_questions > 0:
        questions = questions[:max_questions]

    templates: list[QuizTemplate] = []
    for idx, item in enumerate(questions, 1):
        if not isinstance(item, dict):
            continue
        q_text = str(item.get("question_text") or "").strip()
        if not q_text:
            continue
        templates.append(

View on GitHub (pinned to 3e82f13042)