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

Open
#1,203 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python, rust, yaml
Domain
build-system, cli

Research direction

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.

Written by the indexing model from the issue text.

Description

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.
Dominant language
Rust
Stars
302
Forks
22
Avg merge
5h 2m
Merged PRs (30d)
213

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from quarto-dev/q2

All issues in quarto-dev/q2

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.