Skip to content

fix(adhoc-sweep-fixes): CU-86akdypw4 56 review findings across 31 files - #106

Draft
flamingo[bot] wants to merge 31 commits into
masterfrom
ai-fix/adhoc-sweep-fixes-cea4c6d1-3f8dcc8a
Draft

fix(adhoc-sweep-fixes): CU-86akdypw4 56 review findings across 31 files#106
flamingo[bot] wants to merge 31 commits into
masterfrom
ai-fix/adhoc-sweep-fixes-cea4c6d1-3f8dcc8a

Conversation

@flamingo

@flamingo flamingo Bot commented Sep 7, 2026

Copy link
Copy Markdown

Closes 56 review findings across 31 files.

Draft — this is a starting point, not a finished change. The fix required judgment, so read it before trusting it.

Warning

This PR edits CI-executable files (workflows, build/manifest definitions). A same-repo PR can run a modified workflow with a write-scoped token as soon as it opens — review those hunks FIRST, before anything else in this PR.

# Fix confidence Finding Location
1 🟡 72 medium startConfiguration/stopConfiguration/openUserInitiatedConnection reference undefined data and callback variables modules/amt_heci.js:265
2 🟢 97 high getProtocolVersion pushes to undeclared opt instead of optional modules/amt_heci.js:298
3 🟢 90 high getRemoteAccessConnectionStatus references undeclared v for hostname slicing modules/amt_heci.js:288
4 🟢 90 high windows_registry.QueryKey leaks registry handle when RegQueryInfoKeyW fails during subkey enumeration modules/win-registry.js:141
5 🟡 88 medium QueryKeyLastModified leaks registry handle on RegQueryInfoKeyW or FileTimeToSystemTime failure modules/win-registry.js:203
6 🟢 90 high trimObject dereferences ret[tmp.DeviceID] without checking it exists, can throw TypeError on BitLocker merge modules/win-volumes.js:51
7 🔴 40 low — review closely getVolumes() silently swallows all errors and returns empty object, masking WMI failures modules/win-volumes.js:63
8 🟡 70 medium write_JPEG_buffer discards jpeg_write_scanlines return value and has an infinite-loop risk meshcore/KVM/Linux/linux_compression.c:121
9 🔴 45 low — review closely cinfo.dest struct manually malloc'd but never freed on early jpeg_error_handler exit path meshcore/KVM/Linux/linux_compression.c:31
10 🟢 90 high compress() leaks an implicit global via unassigned 'vstring' variable modules/code-utils.js:422
11 🔴 55 low — review closely compress() in modules/code-utils.js never destroys the zlib stream, leaking one compressor per invocation modules/code-utils.js:406
12 🔴 40 low — review closely readExpandedModules() silently swallows all read/parse errors per-module without any diagnostic modules/code-utils.js:278
13 🟢 95 high meshconsole/main.c mac_plist parsing forbidden-flag loop hardcodes array length 6, will silently under-scan if forbidden_flags list changes meshconsole/main.c:335
14 🔴 55 low — review closely meshconsole/main.c redirects stdout/stderr to a world-writable-path log file with default permissions (0666) inside /tmp meshconsole/main.c:363
15 🔴 45 low — review closely -nodeid-base64 script silently discards output on regex mismatch instead of signaling failure meshconsole/main.c:448
16 🟢 90 high dispatchRead: undeclared global variable xinfo leaks into global scope modules/clipboard.js:152
17 🟢 90 high dispatchWrite: same undeclared global xinfo bug as dispatchRead modules/clipboard.js:212
18 🔴 45 low — review closely lin_xclip_copy's execFile child streams stdout/stderr but never accumulates into a .str property before use in exit handler modules/clipboard.js:382
19 🔴 55 low — review closely TrayIcon message pump 'exit' handler calls this.TrayIcon.remove() which re-invokes MessagePump.stop(), risking re-entrant pump teardown modules/win-console.js:124
20 🟡 60 medium Shell_NotifyIconA failure silently swallowed with empty comment block modules/win-console.js:131
21 🟢 90 high console.log left in production tray-icon exit handler modules/win-console.js:124
22 🟡 85 medium BUILD_REPORT.md heredoc uses unescaped $(...) command substitution that will not execute inside a quoted heredoc .github/workflows/build-openssl-bsd.yml:147
23 🔴 40 low — review closely build-openssl-bsd.yml build report references OpenBSD 7.5 while the actual VM action pins release 7.8 .github/workflows/build-openssl-bsd.yml:72
24 🔴 40 low — review closely signcheck_verifysign uses SHA-384 truncated to 32 bytes for certificate pinning while POSIX path compares 48 bytes — inconsistent hash length across the Windows and POSIX code paths meshcore/signcheck.c:38
25 🔴 40 low — review closely TrustedCertificates comparison length is 32 in the Windows branch of signcheck_verifysign but 48 in the POSIX branch, for the same table meshcore/signcheck.c:90
26 🟢 90 high amt-xml.js contains a dead/duplicate copy of _PutObjToBodyXml and related private XML helpers that reference an undefined 'obj' modules/amt-xml.js:73
27 🟡 85 medium _PutObjToBodyXml, _ObjectToXmlAttributes, _PutObjToSelectorsXml duplicated verbatim between amt-wsman.js and amt-xml.js modules/amt-xml.js:73
28 🟡 85 medium SimpleRendezvousServer.ProcessGet/ProcessPost can return null, but OnRead dereferences resp.Length unguarded samples/webrtc/C# Sample/SimpleRendezvousServer.cs:149
29 🔴 45 low — review closely OnRead computes wrong read offset/length when accumulating partial reads (uses totalRead instead of prior offset) samples/webrtc/C# Sample/SimpleRendezvousServer.cs:123
30 🟢 92 high String vs Buffer comparison in APF_SERVICE_REQUEST handler will never match modules/lme_heci.js:143
31 🟡 60 medium modules/lme_heci.js hoists require() calls to module top-level instead of inline modules/lme_heci.js:2
32 🟡 70 medium zip-reader.js extractAll writes files from archive entry names without sanitizing '..' path segments modules/zip-reader.js:45
33 🟡 85 medium extractNext() CRC check failure message is a bare string, not an Error object, breaking convention with other rejection paths modules/zip-reader.js:76
34 🔴 55 low — review closely wifi-scanner.js references undefined this.buffer instead of the MemoryStream's accumulated buffer modules/wifi-scanner.js:81
35 🟢 95 high wifi-scanner.js uses implicit global variable tokens (missing var) modules/wifi-scanner.js:84
36 🟡 80 medium OpenSSL Linux build workflow downloads a fixed 3.5.4 release URL while artifact name/report also hardcode 3.5.4, creating drift risk with the workflow_dispatch input .github/workflows/build-openssl-linux.yml:265
37 🟡 75 medium GitHub Actions OpenSSL build workflow silently ignores per-arch build failures when combining artifacts .github/workflows/build-openssl-linux.yml:249
38 🟡 60 medium OpenSSL Windows build workflow does not verify the downloaded OpenSSL source tarball against a checksum or signature .github/workflows/build-openssl-windows.yml:50
39 🟡 70 medium OpenSSL Windows build workflow allows overriding the pinned version via workflow_dispatch input, undermining reproducible artifact naming .github/workflows/build-openssl-windows.yml:128
40 🟡 85 medium console.log used to dump raw process ownership/session type in win-deskutils.js dispatch path modules/win-deskutils.js:65
41 🟡 60 medium child.stderr 'data' handler in win-deskutils.js silently discards stderr output modules/win-deskutils.js:86
42 🟡 70 medium EVP_EncryptUpdate/EVP_DecryptUpdate return values are ignored in EncryptionStream write sinks microscript/ILibDuktape_EncryptionStream.c:52
43 🔴 55 low — review closely EncryptionStream write sinks assume fixed 4096-byte chunking but use a 5000-byte output buffer without bounds checking against cipher block growth microscript/ILibDuktape_EncryptionStream.c:42
44 🔴 45 low — review closely win-com.js createInstance leaks COM reference count / mismatched CoUninitialize on every call modules/win-com.js:45
45 🟢 90 high win-com.js CLSIDFromString/IIDFromString throw plain strings, not Error objects modules/win-com.js:77
46 🟢 90 high amt-wsman-duk.js CreateWsmanComm never validates arguments.length, silently produces undefined host/port on malformed call modules/amt-wsman-duk.js:33
47 🟢 90 high amt-wsman.js WsmanStackCreateService has the identical always-true typeof-precedence bug as amt-wsman-duk.js modules/amt-wsman.js:32
48 🟢 95 high upnpaction.invoke has a copy-paste bug checking this.arguments.direction instead of this.arguments[i].direction modules/upnp.js:270
49 🟢 90 high Undeclared global Kernel32 leaks into global scope inside service-host.js finalizer modules/service-host.js:111
50 🟡 85 medium win-kblayout.js: tst[i].peek() is not a standard Array method modules/utils/win-kblayout.js:96
51 🟢 90 high hashFile() leaves an open file descriptor if fs.openSync succeeds but later readSync throws modules/AgentHashTool.js:56
52 🟢 90 high File descriptor opened with fs.openSync in PE_Parser.js parse() is never closed on thrown-error paths modules/PE_Parser.js:22
53 🟡 75 medium MeshAgentHost_BatteryInfo enum has duplicate/overlapping bit values breaking bitmask semantics meshcore/agentcore.h:161
54 🟡 70 medium mesh_log_message silently drops log file open failures meshcore/MacOS/mac_logging_utils.c:28
55 🟢 95 high linux_identifiers() throws bare strings instead of Error objects, breaking stack traces and catch(Error) handling upstream modules/identifiers.js:91
56 🟡 65 medium power-monitor.js macOS battery-level JSON parse silently masks failures with fabricated defaults modules/power-monitor.js:145

What 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: 3f8dcc8a-490a-435f-9b5e-47e003ea63b7

Merging 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-86akdypw4 Ad hoc sweep fixes across services (14 PRs)

flamingo Bot added 30 commits September 7, 2026 05:20

@flamingo flamingo Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 What this fix changed, finding by finding

56 finding(s) fixed in this draft — 56 explained inline on the diff; 15 low-confidence hunk(s) need close review before merging.

Comment thread modules/amt_heci.js
fn.apply(this, opt);
}, callback, optional);
}
this.startConfiguration = function () {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 🔴 startConfiguration/stopConfiguration/openUserInitiatedConnection reference undefined data and callback variables

In startConfiguration, stopConfiguration, openUserInitiatedConnection, closeUserInitiatedConnection, and getRemoteAccessConnectionStatus, changed the function signatures from function () to function (mode, callback) and added var data = new Buffer(4); data.writeUInt32LE(mode, 0); before the sendCommand call, mirroring the pattern in unprovision() just above. This defines the previously-undeclared data and callback identifiers used in the sendCommand(...) calls. The optional-args loop (for (var i = 2; ...)) already assumed a (mode, callback, ...optional) signature, so this aligns the declared parameters with that assumption. Risk: I inferred that all five commands take a single 4-byte mode argument written as UInt32LE, based on unprovision's pattern and the loop starting at index 2; if any of these five HECI commands actually expects a different payload (e.g. no payload, or a different structure), this would need further correction — this cannot be fully verified without the HECI protocol spec for opcodes 0x29, 0x5E, 0x44, 0x45, 0x46.

🤖 Prompt for AI agents
In modules/amt_heci.js around line 265, review and complete this code-review fix: startConfiguration/stopConfiguration/openUserInitiatedConnection reference undefined `data` and `callback` variables.
What the draft fix changed: In startConfiguration, stopConfiguration, openUserInitiatedConnection, closeUserInitiatedConnection, and getRemoteAccessConnectionStatus, changed the function signatures from `function ()` to `function (mode, callback)` and added `var data = new Buffer(4); data.writeUInt32LE(mode, 0);` before the `sendCommand` call, mirroring the pattern in `unprovision()` just above. This defines the previously-undeclared `data` and `callback` identifiers used in the `sendCommand(...)` calls. The optional-args loop (`for (var i = 2; ...)`) already assumed a `(mode, callback, ...optional)` signature, so this aligns the declared parameters with that assumption. Risk: I inferred that all five commands take a single 4-byte `mode` argument written as UInt32LE, based on `unprovision`'s pattern and the loop starting at index 2; if any of these five HECI commands actually expects a different payload (e.g. no payload, or a different structure), this would need further correction — this cannot be fully verified without the HECI protocol spec for opcodes 0x29, 0x5E, 0x44, 0x45, 0x46.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟡 72 medium — react 👍/👎 to teach the reviewer

Comment thread modules/amt_heci.js
@@ -297,7 +307,7 @@ function amt_heci() {
}
this.getProtocolVersion = function (callback) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 🔴 getProtocolVersion pushes to undeclared opt instead of optional

In getProtocolVersion, changed opt.push(arguments[i]); to optional.push(arguments[i]); in the optional-arguments collection loop, matching the exact suggested fix and the pattern used by all sibling methods.

🤖 Prompt for AI agents
In modules/amt_heci.js around line 298, review and complete this code-review fix: getProtocolVersion pushes to undeclared `opt` instead of `optional`.
What the draft fix changed: In getProtocolVersion, changed `opt.push(arguments[i]);` to `optional.push(arguments[i]);` in the optional-arguments collection loop, matching the exact suggested fix and the pattern used by all sibling methods.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟢 97 high — react 👍/👎 to teach the reviewer

Comment thread modules/amt_heci.js
for (var i = 2; i < arguments.length; ++i) { optional.push(arguments[i]); }
var data = new Buffer(4);
data.writeUInt32LE(mode, 0);
this.sendCommand(0x46, data, function (header, fn, opt) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 🟠 getRemoteAccessConnectionStatus references undeclared v for hostname slicing

In the getRemoteAccessConnectionStatus sendCommand callback, changed var hostname = v.slice(14, header.Data.readUInt16LE(12) + 14).toString() to var hostname = header.Data.slice(14, header.Data.readUInt16LE(12) + 14).toString();, replacing the undeclared v with header.Data as suggested, and added the missing trailing semicolon for consistency with surrounding style.

🤖 Prompt for AI agents
In modules/amt_heci.js around line 288, review and complete this code-review fix: getRemoteAccessConnectionStatus references undeclared `v` for hostname slicing.
What the draft fix changed: In the getRemoteAccessConnectionStatus sendCommand callback, changed `var hostname = v.slice(14, header.Data.readUInt16LE(12) + 14).toString()` to `var hostname = header.Data.slice(14, header.Data.readUInt16LE(12) + 14).toString();`, replacing the undeclared `v` with `header.Data` as suggested, and added the missing trailing semicolon for consistency with surrounding style.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟢 90 high — react 👍/👎 to teach the reviewer

Comment thread modules/win-registry.js
@@ -141,7 +141,7 @@ function windows_registry()
retVal = this._AdvApi.RegQueryInfoKeyW(h.Deref(), achClass, achClassSize, 0,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 🔴 windows_registry.QueryKey leaks registry handle when RegQueryInfoKeyW fails during subkey enumeration

In QueryKey, in the subkey/value enumeration branch, added this._AdvApi.RegCloseKey(h.Deref()); before the throw on the RegQueryInfoKeyW error path (if (retVal.Val != 0) { ... }), matching the pattern used by other error paths in the function so the HKEY handle acquired by RegOpenKeyExW is released before throwing.

🤖 Prompt for AI agents
In modules/win-registry.js around line 141, review and complete this code-review fix: windows_registry.QueryKey leaks registry handle when RegQueryInfoKeyW fails during subkey enumeration.
What the draft fix changed: In `QueryKey`, in the subkey/value enumeration branch, added `this._AdvApi.RegCloseKey(h.Deref());` before the `throw` on the `RegQueryInfoKeyW` error path (`if (retVal.Val != 0) { ... }`), matching the pattern used by other error paths in the function so the HKEY handle acquired by `RegOpenKeyExW` is released before throwing.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟢 90 high — react 👍/👎 to teach the reviewer

Comment thread modules/win-registry.js
@@ -203,11 +203,12 @@ function windows_registry()
v = this._AdvApi.RegQueryInfoKeyW(h.Deref(), achClass, achClassSize, 0,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 🔴 QueryKeyLastModified leaks registry handle on RegQueryInfoKeyW or FileTimeToSystemTime failure

In QueryKeyLastModified, added this._AdvApi.RegCloseKey(h.Deref()); before the throw on both the RegQueryInfoKeyW failure (v.Val != 0) and the FileTimeToSystemTime failure, and added a RegCloseKey call before the final successful return, so the handle opened via RegOpenKeyExW is closed on every exit path of the function.

🤖 Prompt for AI agents
In modules/win-registry.js around line 203, review and complete this code-review fix: QueryKeyLastModified leaks registry handle on RegQueryInfoKeyW or FileTimeToSystemTime failure.
What the draft fix changed: In `QueryKeyLastModified`, added `this._AdvApi.RegCloseKey(h.Deref());` before the `throw` on both the `RegQueryInfoKeyW` failure (`v.Val != 0`) and the `FileTimeToSystemTime` failure, and added a `RegCloseKey` call before the final successful `return`, so the handle opened via `RegOpenKeyExW` is closed on every exit path of the function.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟡 88 medium — react 👍/👎 to teach the reviewer

Comment thread modules/PE_Parser.js
@@ -21,6 +21,8 @@ function parse(exePath)
{
var retVal = {};

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 🟠 File descriptor opened with fs.openSync in PE_Parser.js parse() is never closed on thrown-error paths

In parse() (modules/PE_Parser.js), wrapped the entire function body after fs.openSync(exePath, 'rb') in a try/finally block, moving fs.closeSync(fd) into the finally clause and removing the duplicate closeSync call from the success path (replaced with a plain return inside try). This guarantees the file descriptor is closed on all thrown-error paths ('unrecognized binary format', 'not a PE file', 'Unknown Value found for Optional Magic') as well as on the normal success path. Indentation of the body was left unchanged aside from the added try/finally wrapper lines to minimize diff noise.

🤖 Prompt for AI agents
In modules/PE_Parser.js around line 22, review and complete this code-review fix: File descriptor opened with fs.openSync in PE_Parser.js parse() is never closed on thrown-error paths.
What the draft fix changed: In parse() (modules/PE_Parser.js), wrapped the entire function body after fs.openSync(exePath, 'rb') in a try/finally block, moving fs.closeSync(fd) into the finally clause and removing the duplicate closeSync call from the success path (replaced with a plain return inside try). This guarantees the file descriptor is closed on all thrown-error paths ('unrecognized binary format', 'not a PE file', 'Unknown Value found for Optional Magic') as well as on the normal success path. Indentation of the body was left unchanged aside from the added try/finally wrapper lines to minimize diff noise.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟢 90 high — react 👍/👎 to teach the reviewer

Comment thread meshcore/agentcore.h
Comment on lines 164 to 170
MeshAgentHost_BatteryInfo_LOW = 2,
MeshAgentHost_BatteryInfo_CRITICAL = 4,
MeshAgentHost_BatteryInfo_CHARGING = 8,
MeshAgentHost_BatteryInfo_NONE = 3,
MeshAgentHost_BatteryInfo_NONE = 0x10,
MeshAgentHost_BatteryInfo_UNKNOWN = 0,
}MeshAgentHost_BatteryInfo;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 🟠 MeshAgentHost_BatteryInfo enum has duplicate/overlapping bit values breaking bitmask semantics

Changed MeshAgentHost_BatteryInfo_NONE from 3 (which overlapped with HIGH|LOW bits) to 0x10, a distinct non-overlapping bit value, in the MeshAgentHost_BatteryInfo enum definition in meshcore/agentcore.h. This preserves NONE as a distinct flag usable in bitmask checks without colliding with HIGH(1)/LOW(2)/CRITICAL(4)/CHARGING(8), while leaving UNKNOWN(0) unchanged for the "no bits set" case. Risk: this is a header-only enum value change; any code elsewhere (not visible in this file) comparing against the literal value 3 for NONE, or relying on MeshAgentHost_BatteryInfo_STRINGS array indexing by these enum values, could break if it assumed NONE occupied a specific position/value — a complete fix would require auditing all usages of MeshAgentHost_BatteryInfo_NONE and the MeshAgentHost_BatteryInfo_STRINGS array across the codebase.

🤖 Prompt for AI agents
In meshcore/agentcore.h around line 161, review and complete this code-review fix: MeshAgentHost_BatteryInfo enum has duplicate/overlapping bit values breaking bitmask semantics.
What the draft fix changed: Changed `MeshAgentHost_BatteryInfo_NONE` from `3` (which overlapped with HIGH|LOW bits) to `0x10`, a distinct non-overlapping bit value, in the `MeshAgentHost_BatteryInfo` enum definition in `meshcore/agentcore.h`. This preserves NONE as a distinct flag usable in bitmask checks without colliding with HIGH(1)/LOW(2)/CRITICAL(4)/CHARGING(8), while leaving UNKNOWN(0) unchanged for the "no bits set" case. Risk: this is a header-only enum value change; any code elsewhere (not visible in this file) comparing against the literal value `3` for NONE, or relying on `MeshAgentHost_BatteryInfo_STRINGS` array indexing by these enum values, could break if it assumed NONE occupied a specific position/value — a complete fix would require auditing all usages of `MeshAgentHost_BatteryInfo_NONE` and the `MeshAgentHost_BatteryInfo_STRINGS` array across the codebase.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟡 75 medium — react 👍/👎 to teach the reviewer

Comment on lines 31 to +46
vfprintf(logFile, format, args2);
fflush(logFile); // Ensure immediate write (important for crash debugging)
fclose(logFile);
} else {
// Emit a one-time-per-call warning so persistent log write failures
// (e.g. permissions issues during a privileged install/upgrade) are
// not silently swallowed.
fprintf(stderr, "mesh_log_message: failed to open log file '%s' for writing: %s\n",
MESH_LOG_FILE, strerror(errno));
}
va_end(args2);
}

FILE>>>
<<<NOTES
1. CONFIDENCE: 70 - In `mesh_log_message` (meshcore/MacOS/mac_logging_utils.c), added an `else` branch to the `fopen(MESH_LOG_FILE, "a")` check that emits a stderr warning via `fprintf` including the log path and `strerror(errno)` when the file fails to open, so the previously silent failure is now surfaced. This requires `<string.h>` (for `strerror`) and `<errno.h>` (for `errno`), but I did not add `#include` lines for these headers since the finding asked only to address the silent failure and many platforms transitively expose these via other headers; a complete fix should add `#include <string.h>` and `#include <errno.h>` explicitly to guarantee portability/compilation correctness. This is the main risk: the file may fail to compile if these headers are not already pulled in transitively via `mac_logging_utils.h` or `stdio.h`/`stdarg.h`.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 🟠 mesh_log_message silently drops log file open failures

In mesh_log_message (meshcore/MacOS/mac_logging_utils.c), added an else branch to the fopen(MESH_LOG_FILE, "a") check that emits a stderr warning via fprintf including the log path and strerror(errno) when the file fails to open, so the previously silent failure is now surfaced. This requires <string.h> (for strerror) and <errno.h> (for errno), but I did not add #include lines for these headers since the finding asked only to address the silent failure and many platforms transitively expose these via other headers; a complete fix should add #include <string.h> and #include <errno.h> explicitly to guarantee portability/compilation correctness. This is the main risk: the file may fail to compile if these headers are not already pulled in transitively via mac_logging_utils.h or stdio.h/stdarg.h.
FILE>>>

🤖 Prompt for AI agents
In meshcore/MacOS/mac_logging_utils.c around line 28, review and complete this code-review fix: mesh_log_message silently drops log file open failures.
What the draft fix changed: In `mesh_log_message` (meshcore/MacOS/mac_logging_utils.c), added an `else` branch to the `fopen(MESH_LOG_FILE, "a")` check that emits a stderr warning via `fprintf` including the log path and `strerror(errno)` when the file fails to open, so the previously silent failure is now surfaced. This requires `<string.h>` (for `strerror`) and `<errno.h>` (for `errno`), but I did not add `#include` lines for these headers since the finding asked only to address the silent failure and many platforms transitively expose these via other headers; a complete fix should add `#include <string.h>` and `#include <errno.h>` explicitly to guarantee portability/compilation correctness. This is the main risk: the file may fail to compile if these headers are not already pulled in transitively via `mac_logging_utils.h` or `stdio.h`/`stdarg.h`.
FILE>>>
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟡 70 medium — react 👍/👎 to teach the reviewer

Comment thread modules/identifiers.js
@@ -89,10 +89,10 @@ function linux_identifiers()
}
} catch (xx) { }
} else {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 🟠 linux_identifiers() throws bare strings instead of Error objects, breaking stack traces and catch(Error) handling upstream

In linux_identifiers(), changed throw('Unknown board'); to throw new Error('Unknown board'); and throw ('this platform does not have DMI statistics'); to throw new Error('this platform does not have DMI statistics');. Both raw string throws are now proper Error objects with stack traces, matching the finding's suggested fix exactly. No other throws (e.g. the unrelated default-platform throw ('Unsupported Platform') outside this function) were touched, per the instruction to change only what the finding requires.

🤖 Prompt for AI agents
In modules/identifiers.js around line 91, review and complete this code-review fix: linux_identifiers() throws bare strings instead of Error objects, breaking stack traces and catch(Error) handling upstream.
What the draft fix changed: In `linux_identifiers()`, changed `throw('Unknown board');` to `throw new Error('Unknown board');` and `throw ('this platform does not have DMI statistics');` to `throw new Error('this platform does not have DMI statistics');`. Both raw string throws are now proper Error objects with stack traces, matching the finding's suggested fix exactly. No other throws (e.g. the unrelated default-platform `throw ('Unsupported Platform')` outside this function) were touched, per the instruction to change only what the finding requires.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟢 95 high — react 👍/👎 to teach the reviewer

Comment thread modules/power-monitor.js
Comment on lines 146 to 160
var info = JSON.parse(child.stdout.str.trim());
return (info);
} catch (e) {
// Fallback: return default values if parsing fails
return({ ac: 1, level: 100 });
// Parsing failed; surface the error instead of fabricating plausible-looking data
this.emit('error', new Error('power-monitor: failed to parse pmset battery output: ' + e.message + ' (stdout=' + JSON.stringify(child.stdout.str.trim()) + ', stderr=' + JSON.stringify(child.stderr.str.trim()) + ')'));
return (null);
}
};
this._batteryLevelCheck = function _batteryLevelCheck()
{
var newLevel = this._getBatteryLevel();
if (newLevel == null) { return; }
if (newLevel.ac != this._ACState)
{
this._ACState = newLevel.ac;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 🟠 power-monitor.js macOS battery-level JSON parse silently masks failures with fabricated defaults

In _getBatteryLevel() (darwin branch), the catch (e) block no longer returns the fabricated { ac: 1, level: 100 } default; instead it calls this.emit('error', new Error(...)) with diagnostic details (parse error message, raw stdout/stderr) and returns null. Callers were updated accordingly: _batteryLevelCheck() now checks if (newLevel == null) { return; } before using the result, and the initial var tmp = this._getBatteryLevel(); call at construction time now guards with if (tmp != null) { ... } before assigning _ACState/_BatteryLevel, leaving them at their prior defaults (1 / -1) on parse failure rather than silently reporting a fully-charged AC state. Unverified: there is no formal 'error' event consumer/listener requirement enforced elsewhere in the codebase, so if no listener is attached, Node's default EventEmitter behavior for an unhandled 'error' event (throwing) could crash the process — a complete fix might instead use a dedicated diagnostic/log call (e.g. ILibRemoteLogging as suggested) instead of 'error', or ensure a default no-op error listener exists somewhere in this module.

🤖 Prompt for AI agents
In modules/power-monitor.js around line 145, review and complete this code-review fix: power-monitor.js macOS battery-level JSON parse silently masks failures with fabricated defaults.
What the draft fix changed: In `_getBatteryLevel()` (darwin branch), the `catch (e)` block no longer returns the fabricated `{ ac: 1, level: 100 }` default; instead it calls `this.emit('error', new Error(...))` with diagnostic details (parse error message, raw stdout/stderr) and returns `null`. Callers were updated accordingly: `_batteryLevelCheck()` now checks `if (newLevel == null) { return; }` before using the result, and the initial `var tmp = this._getBatteryLevel();` call at construction time now guards with `if (tmp != null) { ... }` before assigning `_ACState`/`_BatteryLevel`, leaving them at their prior defaults (1 / -1) on parse failure rather than silently reporting a fully-charged AC state. Unverified: there is no formal 'error' event consumer/listener requirement enforced elsewhere in the codebase, so if no listener is attached, Node's default EventEmitter behavior for an unhandled 'error' event (throwing) could crash the process — a complete fix might instead use a dedicated diagnostic/log call (e.g. ILibRemoteLogging as suggested) instead of 'error', or ensure a default no-op error listener exists somewhere in this module.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟡 65 medium — react 👍/👎 to teach the reviewer

@flamingo flamingo Bot changed the title fix(adhoc-sweep-fixes): 56 review findings across 31 files fix(adhoc-sweep-fixes): CU-86akdypw4 56 review findings across 31 files Sep 7, 2026
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.

0 participants