rohitg00/ai-engineering-from-scratch · error · PaperValidationError

section {sec.id!r} references unknown figure id {fid!r}

Error message

section {sec.id!r} references unknown figure id {fid!r}

What it means

Error "section {sec.id!r} references unknown figure id {fid!r}" thrown in rohitg00/ai-engineering-from-scratch.

Source

Thrown at phases/19-capstone-projects/54-paper-writer/code/main.py:101

    for fig in paper.figures:
        if fig.id in fig_ids:
            raise PaperValidationError(f"duplicate figure id: {fig.id}")
        fig_ids.add(fig.id)

    bib_keys: set[str] = set()
    for b in paper.bibliography:
        if b.key in bib_keys:
            raise PaperValidationError(f"duplicate bibliography key: {b.key}")
        bib_keys.add(b.key)
    for sec in paper.sections:
        for key in sec.cites:
            if key not in bib_keys:
                raise PaperValidationError(
                    f"section {sec.id!r} cites unknown bibliography key {key!r}"
                )
        for fid in sec.figure_refs:
            if fid not in fig_ids:
                raise PaperValidationError(
                    f"section {sec.id!r} references unknown figure id {fid!r}"
                )


def _escape_latex(text: str) -> str:
    repl = {
        "\\": r"\textbackslash{}",
        "&": r"\&",
        "%": r"\%",
        "$": r"\$",
        "#": r"\#",
        "_": r"\_",
        "{": r"\{",
        "}": r"\}",
        "~": r"\textasciitilde{}",
        "^": r"\textasciicircum{}",
    }
    out_chars: list[str] = []

View on GitHub (pinned to 39ea8a1c6d)

When it happens

Trigger: Thrown at phases/19-capstone-projects/54-paper-writer/code/main.py:101 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of rohitg00/ai-engineering-from-scratch@39ea8a1c6d (2026-08-26). Data as JSON: /api/errors/db530576bd222c91. Report an issue: GitHub.