rohitg00/ai-engineering-from-scratch · error · PaperValidationError
duplicate figure id: {fig.id}
Error message
duplicate figure id: {fig.id} What it means
Error "duplicate figure id: {fig.id}" thrown in rohitg00/ai-engineering-from-scratch.
Source
Thrown at phases/19-capstone-projects/54-paper-writer/code/main.py:85
abstract: str
sections: list[Section] = field(default_factory=list)
figures: list[Figure] = field(default_factory=list)
bibliography: list[BibEntry] = field(default_factory=list)
ProseGenerator = Callable[[Section, Paper], str]
def _validate(paper: Paper) -> None:
if not paper.title.strip():
raise PaperValidationError("title is empty")
if not paper.abstract.strip():
raise PaperValidationError("abstract is empty")
fig_ids: set[str] = set()
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}"
)View on GitHub (pinned to 39ea8a1c6d)
When it happens
Trigger: Thrown at phases/19-capstone-projects/54-paper-writer/code/main.py:85 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/8f790f2e5f0a9e79.
Report an issue: GitHub.