A page that fails to parse is left out of a website render, links to it break, and `post-render` doesn't run

Abierto
#1,203 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
30/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python, rust, yaml
Área
build-system, cli

Línea de trabajo

Start with the render path that prints 'profile-pass skipped' and the Q-13-1/Q-13-4 sidebar and link checks, then trace how a failed parse marks a page as missing from the project index. Repro is in the issue: a website with a bad.qmd that fails to parse, then check whether post-render runs and whether _site/index.html keeps href="bad.qmd". Done means the failed page is reported as an error, the follow-on warnings name the parse failure instead of a spelling mistake, and the exit status and post-render behavior are consistent.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

This issue was written by Claude while adding q2 support to Great Docs. The output shown comes from running each repro.

Bug description

When one page of a website fails to parse, q2 renders the other pages and leaves that page out of
the site entirely. The parse error itself is clear and has a location. What follows is not:

  1. The error is labeled a warning. It prints as
    warning: profile-pass skipped <file>: Error: [Q-2-7] …, but the summary counts it as an error.
  2. The follow-on warnings blame the wrong file. Every sidebar entry and link to the dropped page
    gets a Q-13-1 or Q-13-4 warning saying it "is not in the project index" and to "check the
    spelling". The real cause is that the target failed to parse.
  3. Links to the dropped page stay .qmd. The rendered HTML keeps href="bad.qmd", in the body
    and in every page's sidebar, so they're broken links in the published site.
  4. post-render doesn't run, and q2 render exits 1. The _site directory is left with the
    pages that rendered, but no post-processing. That's neither the full site nor a clean failure.
  5. A single-file render fails because of other pages. q2 render good.qmd reports
    bad.qmd's error and exits 1, even though good.qmd rendered.

q2's parser is stricter than Pandoc's, so many pages that Quarto 1 renders fail to parse under q2.
That makes this path common for existing sites. Great Docs' own docs have about 90 such pages under
q2. Great Docs' post-render scripts build shared sidebars, clean the search index and write page
tags, so skipping them breaks the whole site rather than one page. Great Docs also renders single
pages (great-docs freeze, example checks, an editor preview) and can't tell success from failure
from the exit status.

Related: #232 (parse errors prevent recovery) and #233 ("Sibling page failed to parse").

Steps to reproduce
mkdir parse-drop && cd parse-drop
cat > _quarto.yml <<'EOF'
project:
  type: website
  post-render: post.py
website:
  sidebar:
    contents:
      - index.qmd
      - good.qmd
      - bad.qmd
EOF
printf 'from pathlib import Path\nPath("post-render-ran.txt").write_text("yes\\n")\n' > post.py
printf -- '---\ntitle: Home\n---\n\nSee [the good page](good.qmd) and [the bad page](bad.qmd).\n' > index.qmd
printf -- '---\ntitle: Good\n---\n\nFine.\n' > good.qmd
printf -- '---\ntitle: Bad\n---\n\nEdit `pyproject.toml`'"'"'s settings.\n' > bad.qmd
q2 render; echo "exit=$?"
ls _site post-render-ran.txt
grep -o 'href="[^"]*bad[^"]*"' _site/index.html _site/good.html
q2 render good.qmd; echo "exit=$?"

bad.qmd fails because of the apostrophe after the code span. That error is expected; this issue is
about what happens to the rest of the render.

Actual behavior
Rendering project: /private/tmp/parse-drop (type: website)
warning: profile-pass skipped /private/tmp/parse-drop/bad.qmd: Error: [Q-2-7] Unclosed Single Quote
   ╭─[ /private/tmp/parse-drop/bad.qmd:5:34 ]
   │
 5 │ Edit `pyproject.toml`'s settings.
   │                      ┬           ┬
   │                      ╰────────────── This is the opening quote. If you need an apostrophe, escape it with a backslash.
   │                                  │
   │                                  ╰── I reached the end of the block before finding a closing "'" for the quote.
───╯

Warning: [Q-13-1] Sidebar references missing document
   ╭─[ /private/tmp/parse-drop/_quarto.yml:9:9 ]
   │
 9 │       - bad.qmd
   │         ───┬───
   │            ╰───── `bad.qmd` is not in the project index.
───╯
ℹ Check the spelling, or confirm the target file is included in the render set.

Affected files: /private/tmp/parse-drop/good.qmd, /private/tmp/parse-drop/index.qmd
Warning: [Q-13-4] Body link references missing document
   ╭─[ /private/tmp/parse-drop/index.qmd:5:50 ]
   │
 5 │ See [the good page](good.qmd) and [the bad page](bad.qmd).
   │                                                  ───┬───
   │                                                     ╰───── `bad.qmd` is not in the project index.
───╯
ℹ Check the spelling, or confirm the target file is included in the render set.

Rendered 2 of 3 files to /private/tmp/parse-drop/_site — 1 error, 3 warnings
exit=1
  • _site has good.html and index.html, and no bad.html.
  • post-render-ran.txt doesn't exist.
  • index.html and good.html link to bad.qmd.
  • q2 render good.qmd prints the same bad.qmd error and Q-13-1 warning, renders good.html,
    reports "Rendered 1 of 3 files … 1 error, 1 warning" and exits 1.

With the apostrophe escaped (`pyproject.toml`\'s), all three pages render, post-render runs
and the exit status is 0. Quarto 1.9.37 renders the original project, including bad.html, runs
post-render and exits 0.

Expected behavior
  • Print a page that failed to parse as an error, and say the page was not rendered.
  • Have the Q-13-1 and Q-13-4 warnings say the target failed to render, or leave them out when
    their target failed, instead of suggesting a spelling mistake.
  • Make the outcome of a failed page consistent. Either the render fails without leaving a partial
    site, or it finishes the site, post-render included, and exits non-zero. An option to choose
    (something like --keep-going) would suit tools like Great Docs, which want the full site plus a
    list of failed pages.
  • For q2 render <files>, base the exit status on the named files, and report other pages' parse
    errors as warnings at most.
Lenguaje dominante
Rust
Estrellas
302
Forks
22
Merge medio
5 h 2 min
PR fusionados (30 d)
213

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de quarto-dev/q2

Todos los issues de quarto-dev/q2

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.