#23161: fix(imessage): parse permission denied errors from imsg rpc plaintext output
channel: imessage
size: S
Cluster:
Error Handling Improvements
Fixes #23133
## Problem
When imsg rpc encounters macOS permission issues accessing chat.db, it emits plaintext error messages like:
```
permissionDenied(path: "/Users/.../chat.db", underlying: authorization denied (code: 23))
```
These lines fail JSON parsing in `IMessageRpcClient.handleLine`, causing:
- Generic 'failed to parse' logs with no actionable guidance
- Channel crashes without clear diagnosis
- Users unable to identify the permission issue
## Solution
1. Add `parseIMessageRpcPlaintextError()` helper to detect permission errors
2. When JSON parse fails, check if line matches `permissionDenied` pattern
3. Extract path and underlying error details
4. Construct actionable error with Full Disk Access remediation
5. Call `failAll()` to propagate error with proper context
6. Mark permission errors as fatal in `probeIMessage` for fast-fail behavior
## Testing
- ✅ Added `client.parse-plaintext-error.test.ts` with permissionDenied cases
- ✅ Updated `probe.test.ts` to verify fatal flag on permission errors
- ✅ All existing iMessage tests pass
- ✅ Full quality gate passes (build, tsgo, lint, test)
## Impact
Users hitting permission issues now see clear guidance:
```
imsg permission denied for /path/to/chat.db (authorization denied);
grant Full Disk Access to the process running OpenClaw/imsg and restart
```
This matches the user's reported issue where `permissionDenied` output was being logged as 'failed to parse...Unexpected token' with no hint about the actual macOS permission problem.
---
**AI-assisted:** Implementation and tests generated with Claude Sonnet 4.5 via OpenClaw autonomous contributor workflow.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds plaintext error parsing to detect macOS permission errors from `imsg rpc` output. When JSON parsing fails, the code now checks for `permissionDenied` patterns and constructs actionable errors with Full Disk Access remediation guidance. The `fatal` flag propagates through probe failures to enable fast-fail behavior.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The changes are well-scoped to error handling, properly tested with unit tests covering both quoted and unquoted path scenarios, and follow existing patterns in the codebase. The regex-based parsing is simple and defensive (returns null for non-matches), and the fatal flag integration is consistent with existing error handling logic.
- No files require special attention
<sub>Last reviewed commit: 460b83e</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#4784: fix(imessage): handle non-JSON output from imsg CLI gracefully
by spiceoogway · 2026-01-30
81.1%
#18664: fix(imessage): honor groupConfig regardless of allowlistEnabled
by brandonwise · 2026-02-16
74.3%
#9173: Fix: Improve error messaging for API rate limits and billing errors
by vishaltandale00 · 2026-02-04
72.4%
#23724: fix(security): sanitize RPC error messages in signal and imessage c...
by kevinWangSheng · 2026-02-22
72.4%
#17380: fix(imessage): reject non-numeric chat_id values to prevent silent ...
by aldoeliacim · 2026-02-15
71.6%
#8642: fix: improve launchctl bootstrap error messages for GUI domain issues
by dbottme · 2026-02-04
71.4%
#5693: fix(chat): display error messages when LLM requests fail
by niemesrw · 2026-01-31
71.0%
#11208: fix(config): prevent __OPENCLAW_REDACTED__ corruption on config writes
by janckerchen · 2026-02-07
70.2%
#15914: feat: add messages.suppressMediaPlaceholders config option
by Shuai-DaiDai · 2026-02-14
70.1%
#18792: docs: add macOS source-run troubleshooting for setup/auth issues
by yash27-lab · 2026-02-17
69.7%