fix(MESHCENT-005): CU-86akhf8u3 win-bcd.js exports two different function sets for the two branches, breaking the caller-agnostic contract of MESHCENT-005/MESHCENT-006-2 - #133
Conversation
… the two branches, breaking the caller-agnostic contract of MESHCENT-005/MESHCENT-006-2
| throw ('win-bcd: this function is not supported when running a 32 bit agent on 64 bit windows'); | ||
| } | ||
|
|
||
| if (require('_GenericMarshal').PointerSize == 4 && require('os').arch() == 'x64') |
There was a problem hiding this comment.
🦩 🟠 win-bcd.js exports two different function sets for the two branches, breaking the caller-agnostic contract of MESHCENT-005/MESHCENT-006-2
In modules/win-bcd.js, added a notSupported() helper function that throws a descriptive error, and changed the '32-bit agent on 64-bit windows' branch's module.exports (around the if (require('_GenericMarshal').PointerSize == 4 && require('os').arch() == 'x64') block) to include getKeys, setKey, deleteKey, and getKey mapped to notSupported, plus a bootMode property (defaulting to 'NORMAL' via Object.defineProperty) so both branches now export the identical API surface. Callers destructuring any of these members will get a callable function/property on both branches instead of undefined; calling the unsupported ones throws a clear error rather than failing silently. Risk: the exact error-throwing convention (string throw vs Error object) and the bootMode fallback value were not specified anywhere in the file, so this is an inferred convention, not a verified one — a complete fix might want a different error type or to log rather than throw depending on caller expectations elsewhere in the codebase.
🤖 Prompt for AI agents
In modules/win-bcd.js around line 123, review and complete this code-review fix: win-bcd.js exports two different function sets for the two branches, breaking the caller-agnostic contract of MESHCENT-005/MESHCENT-006-2.
What the draft fix changed: In `modules/win-bcd.js`, added a `notSupported()` helper function that throws a descriptive error, and changed the '32-bit agent on 64-bit windows' branch's `module.exports` (around the `if (require('_GenericMarshal').PointerSize == 4 && require('os').arch() == 'x64')` block) to include `getKeys`, `setKey`, `deleteKey`, and `getKey` mapped to `notSupported`, plus a `bootMode` property (defaulting to `'NORMAL'` via `Object.defineProperty`) so both branches now export the identical API surface. Callers destructuring any of these members will get a callable function/property on both branches instead of `undefined`; calling the unsupported ones throws a clear error rather than failing silently. Risk: the exact error-throwing convention (string throw vs Error object) and the `bootMode` fallback value were not specified anywhere in the file, so this is an inferred convention, not a verified one — a complete fix might want a different error type or to log rather than throw depending on caller expectations elsewhere in the codebase.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟡 65 medium — react 👍/👎 to teach the reviewer
Closes findings from rule MESHCENT-005 — win-bcd.js exports two different function sets for the two branches, breaking the caller-agnostic contract of MESHCENT-005/MESHCENT-006-2.
Draft — this is a starting point, not a finished change. The fix required judgment, so read it before trusting it.
modules/win-bcd.js:123What changed — and what was deliberately left — is explained per finding as inline review comments on the lines each finding touched.
Run: https://product-hub.flamingo.so/admin/code-review
Run id:
bc788a01-3d0c-4679-816f-282037bb5004Merging this PR is recorded as acceptance of the rule that produced it;
closing it unmerged is recorded as rejection. Both feed rule health, so
closing a wrong suggestion is useful rather than merely tidy.
ClickUp task: CU-86akhf8u3 MeshAgent review findings sweep (13 PRs)