Skip to content

Resolve leading-/ include paths against the project root (bd-w9koo1i2) - #468

Merged
cscheid merged 2 commits into
mainfrom
bugfix/bd-w9koo1i2-include-root-relative
Aug 7, 2026
Merged

Resolve leading-/ include paths against the project root (bd-w9koo1i2)#468
cscheid merged 2 commits into
mainfrom
bugfix/bd-w9koo1i2-include-root-relative

Conversation

@cscheid

@cscheid cscheid commented Aug 7, 2026

Copy link
Copy Markdown
Member

Summary

{{< include /admin/_includes/license-file.qmd >}} failed with Q-17-2: the leading-/ path was handed to the filesystem as an OS-absolute path. Per the Quarto path convention (Q1's resolvePath in core/handlers/base.ts, q2's own glob decision D2), a leading / is project-root-relative. Found porting the posit-connect docs to Quarto 2.

The defect: base_dir.join(&include_path)Path::join discards its base when the right-hand side is absolute.

Changes

  • include_expansion.rs: new resolve_include_target() anchors leading-/ (or Windows-authored \) paths at ctx.project.dir; everything else resolves against the including file's directory, unchanged. ProjectContext.dir already matches Q1's anchor in both modes (project root, or the input file's directory for single-file renders), so no mode branch is needed. The root anchor stays fixed at every include-nesting level. Also fixes the same class of failure in the WASM/hub-client build, where a leading-/ path escaped the /project/ VFS root.
  • quarto-preview/deps.rs: extract_include_deps mirrors the same anchors — previously a leading-/ include never matched the SPA's project-relative dep strings, so editing the included file didn't re-render the includer in q2 preview.
  • docs/errors/include/Q-17-2.qmd: documented the old behavior ("not the project root"); now describes both anchors.

Tests (TDD)

  • 5 integration tests (include_project_absolute.rs) driving the real HTML pipeline through ProjectContext::discover on temp-dir layouts: project mode, cross-tree target, single-file parity, nested leading-/, relative regression guard. The four leading-/ tests failed with Q-17-2 before the fix.
  • 4 unit tests for resolve_include_target; 1 preview deps unit test (failed pre-fix returning the raw absolute path).
  • Full workspace: 11060 tests pass; full cargo xtask verify (including WASM + hub-client legs) green.

End-to-end verification

  • Minimal repro project: q2 render now emits no warnings and the rendered sub/doc.html contains the included marker (inspected).
  • posit-connect docs port: Q-17-2 warnings went from many to 0; the license-file callout content appears 5× in rendered admin/licensing/index.html, one per former warning site.

Plan: claude-notes/plans/2026-08-07-include-project-absolute-paths.md
Strand: bd-w9koo1i2 (docs follow-up filed as bd-ehp5ardt)

🤖 Generated with Claude Code

cscheid and others added 2 commits August 7, 2026 17:52
{{< include /path/from/root.qmd >}} was handed to the filesystem as an
OS-absolute path: Path::join discards its base when the right-hand side
is absolute, so the Quarto convention that a leading `/` means
project-root-relative (Q1 resolvePath, glob decision D2) never applied
and every such include failed with Q-17-2. Found porting the
posit-connect docs to Quarto 2.

- include_expansion.rs: new resolve_include_target() anchors leading-/
  (or Windows-authored \) paths at ctx.project.dir — which already
  matches Q1's anchor in both modes (project root, or the input file's
  directory for single-file renders) — and everything else at the
  including file's directory, unchanged. The root anchor stays fixed at
  every nesting level.
- quarto-preview deps.rs: extract_include_deps mirrors the same rule;
  a leading-/ include previously fell through normalize_forward_slash's
  RootDir fallback and never matched the SPA's project-relative paths,
  so editing the included file did not re-render the includer.
- Tests: 5 new integration tests (ProjectContext::discover-based
  harness: project mode, cross-tree target, single-file parity, nested
  leading-/, relative regression guard), 4 unit tests for the helper,
  1 preview deps test. The leading-/ tests failed with Q-17-2 pre-fix.
- docs/errors/include/Q-17-2.qmd documented the old behavior ("not the
  project root"); now describes both anchors.

Plan: claude-notes/plans/2026-08-07-include-project-absolute-paths.md

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@posit-snyk-bot

posit-snyk-bot commented Aug 7, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@cscheid
cscheid merged commit b0f67b4 into main Aug 7, 2026
8 checks passed
@cscheid
cscheid deleted the bugfix/bd-w9koo1i2-include-root-relative branch August 7, 2026 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants