Skip to content

investigate: typst PDF and LaTeX (texToPdf) recipe complete callbacks read format state from the captured construction-time format parameter #14516

@cderv

Description

@cderv

Note-for-later, no current reproducer. Spawned by the analysis for #14511.

Context

In #14511 the typst PDF recipe's complete callback (src/command/render/output-typst.ts) was observed to read format.metadata[kFontPaths] from the format parameter captured at recipe construction. For book projects, withBookTitleMetadata (src/project/types/book/book-render.ts:724) deep-clones and reassigns recipe.format between recipe construction and renderPandoc, so the captured reference becomes stale. resolveExtras then mutates the new (post-clone) recipe.format.metadata, but the recipe's complete never sees it.

The committed fix reads from pandocOptions.format (the live reference). See PR for #14511.

Concern by analogy

texToPdfOutputRecipe (src/command/render/output-tex.ts) has the same capture-the-parameter pattern in its complete callback. Specifically:

  • It reads format.render[kKeepTex] from the captured format (around line 105).
  • The PDF-standard fallback chain at lines 93–94 also reads from the captured format.

LaTeX/PDF book formats are single-file (they do NOT set multiFile: true), so they DO go through renderSingleFileBookwithBookTitleMetadata → deep-clone. The structural exposure is identical to the typst case.

Why this isn't an active bug today

No current pipeline step mutates format.render[kKeepTex] or format.metadata[kPdfStandard] between recipe construction and complete. The known post-construction mutations in pandoc.ts (kTocTitle at ~498, kAbstractTitle at ~521, user pandoc metadata merge at ~466) touch different keys.

Asks for whoever picks this up

  1. Confirm there is genuinely no current execution path that flips kKeepTex or kPdfStandard after recipe construction for a PDF book — if there is, it's the same class of bug as typst book: brand fonts downloaded but not passed to typst compile (unknown font family warning) #14511 and reproducible.
  2. If confirmed latent: either (a) apply the same pandocOptions.format read for symmetry and defense-in-depth, or (b) close as won't-fix with a comment in output-tex.ts explaining why the snapshot is intentional.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions