fix(daemon): reject pid <= 0 in parseLaunchctlPrint#39281
fix(daemon): reject pid <= 0 in parseLaunchctlPrint#39281mvanhorn wants to merge 2 commits intoopenclaw:mainfrom
Conversation
When launchctl print reports pid = 0 (no running process), the parser stores pid: 0, which is semantically incorrect (PID 0 is the kernel scheduler). The systemd parser already checks pid > 0; align launchd parser for consistency. Fixes openclaw#39188 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Greptile SummaryThis PR fixes a semantic bug in Changes:
Safety: Coverage gap: Confidence Score: 4/5
Last reviewed commit: 304b45e |
| if (pidValue) { | ||
| const pid = Number.parseInt(pidValue, 10); | ||
| if (Number.isFinite(pid)) { | ||
| if (Number.isFinite(pid) && pid > 0) { |
There was a problem hiding this comment.
Missing test coverage for the new guard.
The PR description's test plan lists three cases as unchecked [ ]:
parseLaunchctlPrintwithpid = 0should not setinfo.pidparseLaunchctlPrintwithpid = 1234should still setinfo.pid = 1234- Negative PIDs should also be rejected
The existing test suite in launchd.test.ts only covers the positive-PID happy path (lines 91–104). Without dedicated tests for pid = 0 and negative PIDs, this guard could silently regress. Consider adding the three cases from the test plan to the "launchd runtime parsing" describe block before merging.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/daemon/launchd.ts
Line: 131
Comment:
Missing test coverage for the new guard.
The PR description's test plan lists three cases as unchecked `[ ]`:
- `parseLaunchctlPrint` with `pid = 0` should not set `info.pid`
- `parseLaunchctlPrint` with `pid = 1234` should still set `info.pid = 1234`
- Negative PIDs should also be rejected
The existing test suite in `launchd.test.ts` only covers the positive-PID happy path (lines 91–104). Without dedicated tests for `pid = 0` and negative PIDs, this guard could silently regress. Consider adding the three cases from the test plan to the `"launchd runtime parsing"` describe block before merging.
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
Fair point - adding test coverage now for all three cases: pid=0 (should not set), pid=1234 (should set), and negative PIDs (should not set).
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Landed from contributor PR #39281 by @mvanhorn. Co-authored-by: Matt Van Horn <[email protected]>
|
Landed on What shipped:
Landed commit: Source PR commits: Thanks @mvanhorn. |
Landed from contributor PR openclaw#39281 by @mvanhorn. Co-authored-by: Matt Van Horn <[email protected]>
Landed from contributor PR openclaw#39281 by @mvanhorn. Co-authored-by: Matt Van Horn <[email protected]>
Landed from contributor PR openclaw#39281 by @mvanhorn. Co-authored-by: Matt Van Horn <[email protected]>
Landed from contributor PR openclaw#39281 by @mvanhorn. Co-authored-by: Matt Van Horn <[email protected]>
Landed from contributor PR openclaw#39281 by @mvanhorn. Co-authored-by: Matt Van Horn <[email protected]>
Landed from contributor PR openclaw#39281 by @mvanhorn. Co-authored-by: Matt Van Horn <[email protected]>
Landed from contributor PR openclaw#39281 by @mvanhorn. Co-authored-by: Matt Van Horn <[email protected]>
Landed from contributor PR openclaw#39281 by @mvanhorn. Co-authored-by: Matt Van Horn <[email protected]> (cherry picked from commit 7f44bc5)
* refactor(discord): extract route resolution helpers (cherry picked from commit c1d07b0) * refactor(discord): extract native command context builder (cherry picked from commit 9d10697) * refactor(discord): extract native command session targets (cherry picked from commit 8f719e5) * fix(discord): default missing native command args (cherry picked from commit eb9e78d) * refactor(discord): extract inbound context helpers (cherry picked from commit 547436b) * refactor(discord): compose native command routes (cherry picked from commit 6016e22) * fix(telegram): honor commands.allowFrom in native command auth (openclaw#39310) * telegram: honor commands.allowFrom in native auth * test(telegram): cover native commands.allowFrom precedence * changelog: note telegram native commands allowFrom fix * Update CHANGELOG.md * telegram: preserve group policy in native command auth * test(telegram): keep commands.allowFrom under group gating (cherry picked from commit c22a445) * Discord: fix native command context test args (cherry picked from commit ad80ecd) * refactor(routing): centralize inbound last-route policy (cherry picked from commit 6a8081a) * refactor(telegram): centralize text parsing helpers (cherry picked from commit e705627) * refactor(telegram): split bot message context helpers (cherry picked from commit c2e1ae6) * fix: isolate TUI /new sessions per client Landed from contributor PR openclaw#39238 by @widingmarcus-cyber. Co-authored-by: Marcus Widing <[email protected]> (cherry picked from commit 4600817) * TUI: type setSession test mocks (cherry picked from commit 6cb889d) * fix(telegram): restore DM draft streaming (cherry picked from commit e45fcc5) * fix(ci): pin multi-arch docker base digests (cherry picked from commit 5759b93) * fix: reject launchd pid sentinel values Landed from contributor PR openclaw#39281 by @mvanhorn. Co-authored-by: Matt Van Horn <[email protected]> (cherry picked from commit 7f44bc5) * refactor: register gateway service adapters (cherry picked from commit bd41326) * fix: resolve cherry-pick type errors (rebrand, gutted modules, lastRoutePolicy) Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * fix: resolve cherry-pick test failures (gutted Dockerfiles, rebrand INSTALL_BROWSER, preflight stub) Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: Vincent Koc <[email protected]> Co-authored-by: Marcus Widing <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]> Co-authored-by: Matt Van Horn <[email protected]> Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
Summary
parseLaunchctlPrint()only checksNumber.isFinite(pid)before storing the PIDsrc/daemon/systemd.ts:122correctly checksNumber.isFinite(pid) && pid > 0launchctl printreportspid = 0(no running process), the launchd parser storespid: 0, which is semantically incorrect (PID 0 is the kernel scheduler)Change
src/daemon/launchd.ts:131Aligns with the systemd parser's guard at
src/daemon/systemd.ts:122.Test plan
parseLaunchctlPrintwithpid = 0should not setinfo.pidparseLaunchctlPrintwithpid = 1234should still setinfo.pid = 1234Fixes #39188
Co-Authored-By: Claude Opus 4.6 [email protected]