fix(docs): resolve metadata paths with zero-width spaces#12044
fix(docs): resolve metadata paths with zero-width spaces#12044danyalahmed1995 wants to merge 1 commit into
Conversation
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
974c00b to
3eae039
Compare
3eae039 to
452c4e4
Compare
There was a problem hiding this comment.
Honestly, this looks like AI slop
Maybe it's a legit fix, but you are not testing the problem end-to-end, and only adding tests for the code you introduced, which doesn't prove anything in practice.
It remains to be proved that the problem is actually solved, and that your PR is not introducing useless code, despite it being "tested."
Before even thinking about implementing a solution, I want to see an end-to-end test case that actually fails on our CI.
Please add a dogfooding test case to our own website, for example, as I did here: #12052
- If I remove your code, the CI must fail with the initial bug report error.
- If I add back your code, the CI must pass, proving that your implementation solves the problem.
Also, this issue is likely to also affect other plugins, so we'd rather implement a generic solution.
|
Honestly yeah i got invested in proving my approach instead of looking at the original end to end failure , I will keep that in mind apologies for that 😅. I am gonna do the testing you asked me to do and come back with a generic solution that doesn't affect other plugins. Thank you for the feedback. |
|
@slorber I reworked the PR around the dogfood repro path from #12052. Locally, with the dogfood
I removed the helper-only test coverage because that was basically redundant and was mainly for proving the approach not the actual repro. I havent made a commit for it because i am still looking for a generic approach as you asked so it doesnt effect other plugins. |
Summary
Fixes #12005.
This PR fixes a docs metadata hash mismatch that can happen when a docs path contains
U+200B ZERO WIDTH SPACE.The original issue reported that a docs page failed to build when placed under:
docs/contribute/vulnerability-report/index.mdxwhile moving the same file elsewhere worked. The repro also showed that Docusaurus wrote one generated docs metadata JSON file, but the MDX loader tried to import another.
After reproducing the issue, the key detail was that the failing folder name was not plain ASCII. In the reporter repro, the actual folder name contains two trailing zero-width spaces:
vulnerability-report<U+200B><U+200B>So the real path is effectively:
docs/contribute/vulnerability-report<U+200B><U+200B>/index.mdxWhat was found
The reporter already narrowed this down to a generated metadata hash mismatch.
I reproduced the issue on Windows with Node
v24.14.1and Docusaurus3.10.1, and confirmed the exact mismatch:I also checked a fresh controlled Docusaurus project and found:
So this is not a problem with the vulnerability-report folder name itself. It is a hidden Unicode path handling issue.
Root cause
Docs metadata is written using the loaded docs source string, but the MDX loader later computes the metadata JSON filename from the loader path.
For paths containing U+200B ZERO WIDTH SPACE, those two strings can differ before docuHash() is called.
That means Docusaurus can write metadata using one source string:
while the MDX loader imports metadata using a different source string:
The result is a hard build failure:
Changes
This PR updates the docs content helpers so the MDX metadata import resolves back to the loaded docs source before hashing.
Instead of hashing only the MDX loader path, the metadata path now goes through the content helper mapping and uses the same source that was used when the docs metadata JSON file was created.
This keeps the generated metadata filename consistent between:
The PR also adds a guard for ambiguous metadata source keys. If two docs paths only differ in a way that would collapse to the same metadata source key, Docusaurus now reports that ambiguity clearly instead of silently choosing one and creating another confusing missing-module failure.
Regression coverage
Added tests for:
Validation
Ran:
Also manually verified before/after behavior for:
Line-ending hygiene was also checked with git diff --check.