Skip to content

fix(@stdlib/_tools/repl-txt/rules/doctest): guard against null alias in replaceAliases#13472

Closed
Planeshifter wants to merge 1 commit into
developfrom
claude/elegant-feynman-ek55jp
Closed

fix(@stdlib/_tools/repl-txt/rules/doctest): guard against null alias in replaceAliases#13472
Planeshifter wants to merge 1 commit into
developfrom
claude/elegant-feynman-ek55jp

Conversation

@Planeshifter

Copy link
Copy Markdown
Member

Description

This pull request:

  • Fixes replaceAliases() in @stdlib/_tools/repl-txt/rules/doctest, which crashed the lint_changed_files job with TypeError: Cannot read properties of null (reading 'split') whenever a docs/repl.txt file references a sibling package via {{alias:pkg}} before that package is indexed in the generated @stdlib/namespace registry (e.g. two sibling packages added in the same commit). pkg2alias() returns null in that case; the call site called .split('.') on it directly. Falls back to 'ALIAS' on a falsy return, matching the identical guard already used earlier in the same file at pkgName = pkg2alias( pkg ) || 'ALIAS';.

Related Issues

None.

Questions

No.

Other

Failing run: https://github.com/stdlib-js/stdlib/actions/runs/29314039197 (job: Lint Changed Files, step: Lint REPL help files)

Symptom: TypeError: Cannot read properties of null (reading 'split') at lib/node_modules/@stdlib/_tools/repl-txt/rules/doctest/lib/main.js:175.

Root cause: unguarded call to pkg2alias(), which returns null for packages not yet present in the generated namespace registry.

Checklist

AI Assistance

  • Yes

  • No

  • Code generation (e.g., when writing an implementation or fixing a bug)

  • Test/benchmark generation

  • Documentation (including examples)

  • Research and understanding

Disclosure

This PR was written by Claude Code as part of an automated CI-failure triage routine: identified the failing job from Actions logs, traced the root cause to the unguarded pkg2alias() call, and validated the fix against the existing guard pattern in the same file. Reviewed by three independent passes (correctness, regression scope, style/conventions); all approved with no blocking findings.


@stdlib-js/reviewers


Generated by Claude Code

…` in `replaceAliases`

The job `Lint Changed Files` on workflow `lint_changed_files` failed on
develop with `TypeError: Cannot read properties of null (reading
'split')` in `replaceAliases`. Root cause: `pkg2alias()` returns `null`
when a referenced package is not yet indexed in the generated
`@stdlib/namespace` registry, which happens when a `repl.txt` file
references a sibling package added in the same commit, before the
`namespace_declarations` workflow regenerates the registry. The
unguarded call site called `.split('.')` directly on that `null`. This
commit falls back to `'ALIAS'` on a falsy return, mirroring the
identical guard already used earlier in the same file (`pkgName =
pkg2alias( pkg ) || 'ALIAS';`) and the resolvable-aliases rule's null
handling, so the lint job no longer crashes on newly added
cross-referencing sibling packages.

Ref: https://github.com/stdlib-js/stdlib/actions/runs/29314039197
@stdlib-bot stdlib-bot added the Tools Issue or pull request related to project tooling. label Jul 14, 2026

@kgryte kgryte left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closing, as I am already working on a fix which is more general.

@kgryte kgryte closed this Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Tools Issue or pull request related to project tooling.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants