Skip to content

fix: warn on a symlinked top-level architecture directory instead of dropping it silently - #1290

Merged
mrbobbytables merged 1 commit into
mainfrom
fix/upstream-symlinked-architecture-dirs
Oct 10, 2026
Merged

mrbobbytables merged 1 commit into
mainfrom
fix/upstream-symlinked-architecture-dirs

Conversation

@mrbobbytables

Copy link
Copy Markdown
Member

Closes #1267. Closes #1276.

One PR for both, as proposed in #1283: the two findings are the same unguarded Dirent.isDirectory() filter over the same third-party input, at two sites.

Finding

Both scripts that enumerate content/en/architectures/ in the cloned cncf/architecture repository filtered on entry.isDirectory(), which is false for a symlink. A symlinked architecture directory upstream was therefore excluded with no log output:

Change

Guard the top-level filter the way walkFiles() already guards every other symlink in the clone (#533, #548): test isSymbolicLink() first and console.warn each skipped entry so the drop is visible in the workflow log. Skipped rather than resolved through realpathSync, so the two scripts agree on which directories exist and the count matches the import.

tests/helpers-script-sandbox.mjs gains a repoSymlinks option mirroring the import harness's upstreamSymlinks; the git clone shim already copies fixtures with cp -R, which preserves links.

Tests

  • tests/import-architectures.test.mjs: a link to a directory outside the tree and a link aliasing a sibling architecture are both skipped and warned about; the real sibling is imported once; neither link produces a page.
  • tests/collect-metrics.test.mjs: a link to a sibling and a dangling link are both skipped and warned about; the count stays at the two real directories.

npm run test:unit:coverage:check: 2317 tests pass, exit 0; both scripts remain at 100% lines and regions. check:format and check:spelling clean.

…dropping it silently

Both scripts that enumerate content/en/architectures/ in the cloned
cncf/architecture repository filtered on Dirent.isDirectory(), which is
false for a symlink. A symlinked architecture directory upstream was
therefore excluded with no log output:

- import-architectures.mjs prunes every imported page before the walk,
  so the architecture's page was deleted and it vanished from the site
  and from catalog.json with nothing in the import log (#1267).
- collect-metrics.mjs published an undercounted Reference architectures
  metric that validate-metrics.mjs never checks (#1276).

Guard the top-level filter the way walkFiles() already guards every
other symlink in the clone: test isSymbolicLink() first and console.warn
each skipped entry so the drop is visible in the workflow log. The two
scripts now agree on which directories exist.

runScriptInSandbox gains a repoSymlinks option mirroring the import
harness's upstreamSymlinks, so a fixture clone can carry a symlink the
same way a committed one would.

Closes #1267
Closes #1276

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Bob Killen <bkillen@linuxfoundation.org>
@mrbobbytables
mrbobbytables added this pull request to the merge queue Oct 10, 2026
Merged via the queue into main with commit cc6b7fa Oct 10, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant