Skip to content

fix(utils): resolve site-relative paths in the eager Git VCS - #12329

Open
alexandrosang21 wants to merge 1 commit into
facebook:mainfrom
alexandrosang21:fix/vcs-eager-relative-source-file-path
Open

fix(utils): resolve site-relative paths in the eager Git VCS#12329
alexandrosang21 wants to merge 1 commit into
facebook:mainfrom
alexandrosang21:fix/vcs-eager-relative-source-file-path

Conversation

@alexandrosang21

Copy link
Copy Markdown

Pre-flight checklist

Left unchecked deliberately: this is a small bug fix rather than a new API or substantial
change, so no working plan was agreed beforehand. It does close #12322.

Motivation

Fixes #12322. With future.experimental_vcs: 'default-v2', sitemap.xml is generated without
any <lastmod> values, while 'git-ad-hoc' and 'default-v1' produce them correctly for the
same site and Git history.

default-v2 selects the eager Git strategy in production. vcsGitEager keys its file map by
absolute paths:

// The Map keys should be absolute file paths, not relative Git paths
return [resolve(repoRoot, entry[0]), entry[1]];

but the lookup uses whatever path it is handed:

return init.filesMap.get(filePath) ?? null;

The sitemap plugin passes route.metadata.sourceFilePath, which RouteMetadata documents as
"expected to be relative to the site directory". So the lookup misses and returns null, and
getRouteLastmod drops <lastmod> for that route without any warning.

git-ad-hoc and default-v1 are unaffected because they shell out to git log -- <path>, which
resolves a relative path itself.

This resolves the path against the site dir when it is not already absolute. Absolute paths keep
working unchanged, so getFileCreationInfo and existing callers are unaffected.

Test Plan

Unit test. Added can read repo file info from a site-relative path to the existing
VSC Git Eager Strategy block. It fails on main and passes with this change. Every existing
eager test passes an absolute path via path.join(repoDir, ...), which is why this gap was not
covered.

pnpm vitest run packages/docusaurus-utils/src/vcs packages/docusaurus-plugin-sitemap
Test Files  5 passed (5)
     Tests  94 passed (94)

eslint, tsc --noEmit, oxfmt --list-different and cspell are all clean on the two changed
files.

End to end, using the reproduction repository from the issue
(eMUQI/docusaurus-vcs-sitemap-repro),
building the same site twice with only this patch differing:

@docusaurus/utils <url> <lastmod>
unmodified 1 0
with this change 1 1

Its npm run verify:repro asserts that default-v2 produces zero <lastmod>, so with the fix
applied that assertion now fails, which is the intended outcome.

Test links

Not applicable: this changes build-time sitemap metadata rather than anything rendered, so there
is no UI to preview.

Disclosure

This change was written with AI assistance (Claude), per the AI policy in CONTRIBUTING.md. I have
reviewed every line, verified the root cause against the reproduction repository above, and can
explain and defend the change in review.

The eager strategy keys its file map by absolute paths, but looks up
whatever path it is handed. RouteMetadata.sourceFilePath is documented as
relative to the site directory, and the sitemap plugin forwards it
unchanged, so the lookup missed and returned null.

The result was a silently missing <lastmod> in sitemap.xml under
experimental_vcs: 'default-v2', which selects the eager strategy in
production. 'git-ad-hoc' and 'default-v1' were unaffected because they
shell out to git log, which resolves relative paths itself.

Resolves the path against the site dir when it is not already absolute.
Every existing eager test passed an absolute path, which is why this was
not caught.
@meta-cla

meta-cla Bot commented Jul 30, 2026

Copy link
Copy Markdown

Hi @alexandrosang21!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@netlify

netlify Bot commented Jul 30, 2026

Copy link
Copy Markdown

[V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit 751e6b2
🔍 Latest deploy log https://app.netlify.com/projects/docusaurus-2/deploys/6a6b353e626be000086532cf
😎 Deploy Preview https://deploy-preview-12329--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@meta-cla meta-cla Bot added the CLA Signed Signed Facebook CLA label Jul 30, 2026
@meta-cla

meta-cla Bot commented Jul 30, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sitemap <lastmod> is omitted with experimental_vcs: 'default-v2' in Docusaurus 3.10.2

1 participant