Skip to content

fix(ci): cache the vendored addon where node-gyp actually writes it - #20445

Merged
nwparker merged 1 commit into
mainfrom
nwparker/registry-addon-followups
Sep 13, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/registry-addon-followups

Conversation

@nwparker

@nwparker nwparker commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​7 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​5
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​17 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​12

Follow-up to #20438, addressing review comments on that PR.

Native cache pointed at a path that cannot exist

Switching @orca/windows-registry from file: to a workspace link means pnpm symlinks node_modules/@orca/windows-registry straight to native/windows-registry — there is no .pnpm/@orca+windows-registry@* entry at all (pnpm-lock.yaml records version: link:native/windows-registry with no packages: entry). All four native-cache blocks globbed that nonexistent path, so the addon was recompiled on every Windows job and the cache-key hardening from #20438 was inert for it.

Fixed in all four blocks — install-node-dependencies/action.yml:153,164 and pr.yml:832,901 are separate configurations — plus the assertion in pr-workflow-parallelism.test.mjs that pinned the stale path.

Two addon hardening fixes

  • Odd-length UTF-16 data. RegEnumValueW reports a byte count and the registry does not enforce whole WCHARs for string types. On an odd count the appended terminator straddles a character boundary, so Napi's NAPI_AUTO_LENGTH scan runs past the value data. Now rejected before both the direct and REG_MULTI_SZ conversions.
  • __proto__ as a value name. getRegistryKey built its result with {}, so a value named __proto__ would reassign the prototype instead of becoming an entry, silently breaking the keyed-value contract. Now Object.create(null).

Both were inherited from windows-native-registry, so neither is a regression — but the source is ours now.

Test robustness

reg.exe echoes the value name as stored, so a machine holding PATH rather than Path would have missed the line and made the oracle look absent. Matched case-insensitively.

Verification

  • Windows (awin): with build/ deleted, ensure-native-runtime.mjs recompiles the hardened addon (gyp info ok) and all 4 addon tests pass
  • pnpm test config/scripts/ — 192 files, 1608 tests passed
  • pnpm tc clean; check:code-quality:changed 0 new findings

The workspace link means pnpm never creates a .pnpm/@orca+windows-registry@*
entry, so all four native-cache blocks globbed a path that cannot exist and
the addon was recompiled on every Windows job.

Also hardens the addon itself: RegEnumValueW reports a byte count and the
registry does not enforce whole WCHARs for string types, so an odd count let
Napi's auto-length scan run past the value; and a value named __proto__ would
reassign the result object's prototype instead of becoming an entry.
@coderabbitai

coderabbitai Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: f0049fba-69c9-475d-9f8b-350b40f5b605

📥 Commits

Reviewing files that changed from the base of the PR and between 5127d1e and 3490cf1.

📒 Files selected for processing (6)
  • .github/actions/install-node-dependencies/action.yml
  • .github/workflows/pr.yml
  • config/scripts/pr-workflow-parallelism.test.mjs
  • native/windows-registry/index.js
  • native/windows-registry/src/addon.cc
  • src/main/windows-registry-addon.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

The Windows registry addon now rejects malformed UTF-16 value sizes and uses a null-prototype result object. Windows Node and Electron native-module cache steps now target native/windows-registry/build. The workflow test checks the updated cache path. The registry test helper now matches value names case-insensitively after trimming.

Priority: ⬇️ Low

Estimated code review effort:

Merge Risk: ⚪ Minimal · up to 3490c

The registry hardening and Windows cache updates are consistent with their consumers and workflow contracts.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the cache fix, addon hardening, test update, and verification results. However, it omits most required template sections, including ELI5, What Changed, Why, Linked Issue with … Rewrite the description using all template headings. Add a linked issue in the required Fixes #... format, state N/A with a reason for Visual Proof, complete the Testing checkboxes and platform details, address AI Disclosure, Review, Ag…
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 4 files. (2 skipped: 2… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: updating CI to cache the vendored addon at the path where node-gyp writes it.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the cache fix, addon hardening, test update, and verification results. However, it omits most required template sections, including ELI5, What Changed, Why, Linked Issue with a Fixes reference, Visual Proof or N/A, Testing checkboxes, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist.

Resolution

Rewrite the description using all template headings. Add a linked issue in the required Fixes #... format, state N/A with a reason for Visual Proof, complete the Testing checkboxes and platform details, address AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist sections, and retain the existing technical details and verification results.

Full details: Docstring Coverage

Explanation

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 4 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes: follow-up to #20438 that repoints the native addon cache at the path node-gyp actually writes, plus two upstream-inherited hardening fixes and a test-oracle tweak.

  • Native cache path corrected — with @orca/windows-registry now a workspace:* link (pnpm-lock.yaml records version: link:native/windows-registry, no .pnpm/@orca+windows-registry@* entry), the four cache blocks at .github/actions/install-node-dependencies/action.yml:153,164 and .github/workflows/pr.yml:838,907 now cache native/windows-registry/build. ensure-native-runtime.mjs resolves the package to its real dir and @electron/rebuild writes in place, so the new path is the one actually populated; the existing key hash already covers addon.cc, binding.gyp, and package.json.
  • __proto__-safe value map — native/windows-registry/index.js:30 builds byName with Object.create(null), so a value literally named __proto__ becomes an own entry rather than reassigning the prototype. The consumers (windows-path-registry-reader.ts, windows-user-path-registry.ts) only use Object.entries(...), which is null-prototype safe.
  • Odd-length UTF-16 rejected — native/windows-registry/src/addon.cc:72-77 rejects REG_SZ / REG_EXPAND_SZ / REG_MULTI_SZ values whose byte length is not a whole number of WCHARs before appending a terminator, keeping the terminator aligned for Napi's NAPI_AUTO_LENGTH scan.
  • Test oracle made case-insensitive — src/main/windows-registry-addon.test.ts:23-28 compares the reg.exe value name case-insensitively, since a machine storing PATH rather than Path would otherwise look absent.

Notes: the two hardening changes are untested (the __proto__ path has no injection seam in the wrapper), and the guard returns null for the whole key on a single malformed value — both defensible, neither blocking.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit 411843f into main Sep 13, 2026
56 checks passed
@nwparker
nwparker deleted the nwparker/registry-addon-followups branch September 13, 2026 03:45
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.

1 participant