Add a `freeze: fail` option that errors on stale or missing frozen results

オープン
#15,407 コメント 1 件 リアクション 1 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
15/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
typescript, yaml

調査の方向性

The change touches renderExecute in src/command/render/render-files.ts, defrostExecuteResult in src/command/render/freeze.ts, and the freeze schema in src/resources/schema/document-execute.yml. Start by reading how the hash comparison and the thawed-result lookup work for auto. Before coding, the open questions need a maintainer decision: whether to report one stale document or all of them, which takes precedence (profile or document), and the value name. Done means the new value is accepted by the schema and fails with a clear error for stale or missing results.

索引モデルが issue の本文から書いたものです。

説明

enhancement freeze projects

Summary

Many projects render in CI from committed _freeze/ files, with no R, Python, or Julia on the runner. A forgotten freeze update is the common mistake in that setup, and Quarto gives no clear signal for it.

I propose freeze: fail: use a frozen result if it is current, and stop with an error that names the document if it is not. The main use is a CI-only project profile.

Value Current result Stale result Missing result
true Use it Use it, with no message Execute
auto Use it Execute Execute
fail (new) Use it Stop, and name the document Stop, and name the document

A result is current if its hash matches the source file. The table describes a full project render (renderExecute, defrostExecuteResult).

The problem

freeze: true (for example, quarto-web). An author edits a computational document and forgets to commit a new _freeze/. Quarto uses the stale result and CI passes. The frozen result holds the full executed markdown, so the published page shows the old document, prose edits included. Nothing in the log or the PR checks points to it. In my clone of quarto-web (commit 001d4331e), 2 of 23 frozen results are stale: docs/interactive/ojs/index.qmd and docs/interactive/widgets/htmlwidgets.qmd.

freeze: auto (for example, a book that renders from freeze in CI). The same mistake makes Quarto execute the document in CI. The runner has R but no packages, so the render fails with this error:

Error in loadNamespace(x) : there is no package called 'rmarkdown'
...
The knitr package is not available in this R installation.
Install with install.packages("knitr")

The rmarkdown package is not available in this R installation.
Install with install.packages("rmarkdown")

WARN: Error encountered when rendering files

The error describes the runner, not the mistake, and it tells the reader to install packages. The usual reaction is to add R and packages to the workflow, which hides the problem and slows the job. This happened in our book repository.

Proposal

# _quarto-ci.yml
execute:
  freeze: fail
quarto render --profile ci
  • With true locally: a stale result fails the PR check before the stale page is published.
  • With auto locally: Quarto stops before the engine starts, and the error is about the freeze, not the runner. Current results are used exactly as today.
  • The local workflow does not change. Authors render with true or auto and commit _freeze/.
  • A targeted render (quarto render doc.qmd) executes with every value today. I suggest that fail keeps this behavior, because that is how an author updates a frozen result.
  • Documents that cannot be frozen (engine: markdown, execute: enabled: false) are not affected.

A possible error message:

ERROR: projects.qmd changed after its results were frozen.
Render the document in an environment that can execute it, then commit _freeze/projects/.

Implementation notes

  • Add the value to the freeze schema and to the kFreeze type.
  • defrostExecuteResult already compares the hash for every value other than true, so fail gets the auto comparison with no change.
  • New logic: in renderExecute, before context.engine.execute(...), throw if the value is fail, canFreeze is true, and there is no thawed result.

Open questions

  • One error or all. Quarto compares hashes one document at a time, in the loop that runs Pandoc. The small change above reports only the first stale document, after it renders all earlier ones. A full list up front needs a new pass over the input files.
  • Precedence. I expect a freeze value in a document or _metadata.yml to take precedence over a profile (not verified). That is a useful exemption for one document, and a problem for a project that sets freeze in each directory.
  • Single-file book formats. A targeted render becomes a full render with the freezer on (bookIncrementalRenderAll), so a stale result in a different chapter stops it.
  • Preview. I suggest that quarto preview treats fail as auto.
  • Name. fail, strict, or require.

Alternatives

  • A render flag or environment variable, like cargo build --locked or npm ci. It overrides freeze values everywhere. A freeze value works with profiles and with every command that renders, such as quarto publish.
  • A CI script that compares the MD5 of each source file with the hash in its frozen result. We plan to do this for now. The script must copy the hash rule and guess which documents need a frozen result.

AI helped with this investigation. It was grounded in local clones of quarto-cli (commit 623cd99e8) and quarto-web (commit 001d4331e).

主要言語
JavaScript
スター
6.2k
フォーク
492
平均マージ
15時間 15分
マージ済み PR(30日)
94

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

quarto-dev/quarto-cli のほかの issue

quarto-dev/quarto-cli の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。