Repository navigation
fix(whatsapp): restore malformed credentials from backup - #99070
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 5, 2026, 9:22 AM ET / 13:22 UTC. Summary PR surface: Source +4, Tests +10. Total +14 across 2 files. Reproducibility: yes. by source inspection rather than a local run. On current main, a multi-byte malformed creds.json value like {x is returned by the raw read helper, reaches JSON.parse(raw), and prevents the valid backup restore path from running. Review metrics: none identified. Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the narrowed WhatsApp auth-store recovery after current-head required checks, keeping release-note context in the PR body or squash message rather than CHANGELOG.md. Do we have a high-confidence way to reproduce the issue? Yes, by source inspection rather than a local run. On current main, a multi-byte malformed creds.json value like {x is returned by the raw read helper, reaches JSON.parse(raw), and prevents the valid backup restore path from running. Is this the best way to solve the issue? Yes. The PR fixes the owner-boundary restore helper, preserves valid primary creds, restores only parseable backups through the existing atomic write helper, and avoids a broader doctor/config migration for a startup recovery path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f9e194e4a122. Label changesLabel justifications:
Evidence reviewedPR surface: Source +4, Tests +10. Total +14 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (4 earlier review cycles)
|
|
@clawsweeper re-review Changes made:
|
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review |
|
@clawsweeper re-review Updated the PR body with L2 real behavior proof:
|
0ad1318 to
0d6678d
Compare
0d6678d to
0940aed
Compare
|
Land-ready proof for exact head
Known local full-suite noise was unrelated process-cleanup timing and Mattermost watchdog behavior; the exact-head hosted matrix is green. |
0940aed to
4cdfea2
Compare
4cdfea2 to
3631f06
Compare
3631f06 to
069070a
Compare
069070a to
4510d36
Compare
…helpers Add defensive try-catch around JSON.parse calls in WhatsApp extension to prevent crashes from corrupted state files. - restoreCredsFromBackupIfNeeded: wrap creds.json/backup validation JSON.parse with try-catch; corrupted creds.json now properly falls through to backup restoration instead of skipping it entirely - updateLastRouteMock: wrap JSON.parse with try-catch, initialize empty store on corrupted file
…han one byte
- Add a focused regression test for the exact case ClawSweeper
flagged: readWebCredsJsonRawSync returns non-null content for
files with stat.size > 1, so malformed JSON like "{x" (2 bytes)
reaches JSON.parse — the inner try-catch now catches the parse
failure and falls through to backup restoration
- Without this patch, JSON.parse("{x") throws to the outer catch
and restoreCredsFromBackupIfNeeded returns false, skipping backup
🦞 diamond lobster: L2 evidence (real function call + real filesystem objects)
Ref. openclaw#99070
Co-authored-by: LeonidasLux <[email protected]>
4510d36 to
09b0d55
Compare
|
Merged via squash.
|
) * fix(whatsapp): wrap JSON.parse with try-catch in auth store and test helpers Add defensive try-catch around JSON.parse calls in WhatsApp extension to prevent crashes from corrupted state files. - restoreCredsFromBackupIfNeeded: wrap creds.json/backup validation JSON.parse with try-catch; corrupted creds.json now properly falls through to backup restoration instead of skipping it entirely - updateLastRouteMock: wrap JSON.parse with try-catch, initialize empty store on corrupted file * test(whatsapp): add regression test for malformed creds.json longer than one byte - Add a focused regression test for the exact case ClawSweeper flagged: readWebCredsJsonRawSync returns non-null content for files with stat.size > 1, so malformed JSON like "{x" (2 bytes) reaches JSON.parse — the inner try-catch now catches the parse failure and falls through to backup restoration - Without this patch, JSON.parse("{x") throws to the outer catch and restoreCredsFromBackupIfNeeded returns false, skipping backup 🦞 diamond lobster: L2 evidence (real function call + real filesystem objects) Ref. openclaw#99070 * fix(whatsapp): restore malformed creds from backup Co-authored-by: LeonidasLux <[email protected]> * docs(changelog): defer credential recovery entry to aggregate --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: LeonidasLux <[email protected]>
) * fix(whatsapp): wrap JSON.parse with try-catch in auth store and test helpers Add defensive try-catch around JSON.parse calls in WhatsApp extension to prevent crashes from corrupted state files. - restoreCredsFromBackupIfNeeded: wrap creds.json/backup validation JSON.parse with try-catch; corrupted creds.json now properly falls through to backup restoration instead of skipping it entirely - updateLastRouteMock: wrap JSON.parse with try-catch, initialize empty store on corrupted file * test(whatsapp): add regression test for malformed creds.json longer than one byte - Add a focused regression test for the exact case ClawSweeper flagged: readWebCredsJsonRawSync returns non-null content for files with stat.size > 1, so malformed JSON like "{x" (2 bytes) reaches JSON.parse — the inner try-catch now catches the parse failure and falls through to backup restoration - Without this patch, JSON.parse("{x") throws to the outer catch and restoreCredsFromBackupIfNeeded returns false, skipping backup 🦞 diamond lobster: L2 evidence (real function call + real filesystem objects) Ref. openclaw#99070 * fix(whatsapp): restore malformed creds from backup Co-authored-by: LeonidasLux <[email protected]> * docs(changelog): defer credential recovery entry to aggregate --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: LeonidasLux <[email protected]> (cherry picked from commit 42464de)
* fix(whatsapp): wrap JSON.parse with try-catch in auth store and test helpers
Add defensive try-catch around JSON.parse calls in WhatsApp extension
to prevent crashes from corrupted state files.
- restoreCredsFromBackupIfNeeded: wrap creds.json/backup validation
JSON.parse with try-catch; corrupted creds.json now properly falls
through to backup restoration instead of skipping it entirely
- updateLastRouteMock: wrap JSON.parse with try-catch, initialize
empty store on corrupted file
* test(whatsapp): add regression test for malformed creds.json longer than one byte
- Add a focused regression test for the exact case ClawSweeper
flagged: readWebCredsJsonRawSync returns non-null content for
files with stat.size > 1, so malformed JSON like "{x" (2 bytes)
reaches JSON.parse — the inner try-catch now catches the parse
failure and falls through to backup restoration
- Without this patch, JSON.parse("{x") throws to the outer catch
and restoreCredsFromBackupIfNeeded returns false, skipping backup
🦞 diamond lobster: L2 evidence (real function call + real filesystem objects)
Ref. openclaw/openclaw#99070
* fix(whatsapp): restore malformed creds from backup
Co-authored-by: LeonidasLux <[email protected]>
* docs(changelog): defer credential recovery entry to aggregate
---------
Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: LeonidasLux <[email protected]>
* fix(whatsapp): wrap JSON.parse with try-catch in auth store and test helpers
Add defensive try-catch around JSON.parse calls in WhatsApp extension
to prevent crashes from corrupted state files.
- restoreCredsFromBackupIfNeeded: wrap creds.json/backup validation
JSON.parse with try-catch; corrupted creds.json now properly falls
through to backup restoration instead of skipping it entirely
- updateLastRouteMock: wrap JSON.parse with try-catch, initialize
empty store on corrupted file
* test(whatsapp): add regression test for malformed creds.json longer than one byte
- Add a focused regression test for the exact case ClawSweeper
flagged: readWebCredsJsonRawSync returns non-null content for
files with stat.size > 1, so malformed JSON like "{x" (2 bytes)
reaches JSON.parse — the inner try-catch now catches the parse
failure and falls through to backup restoration
- Without this patch, JSON.parse("{x") throws to the outer catch
and restoreCredsFromBackupIfNeeded returns false, skipping backup
🦞 diamond lobster: L2 evidence (real function call + real filesystem objects)
Ref. openclaw/openclaw#99070
* fix(whatsapp): restore malformed creds from backup
Co-authored-by: LeonidasLux <[email protected]>
* docs(changelog): defer credential recovery entry to aggregate
---------
Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: LeonidasLux <[email protected]>
What Problem This Solves
A malformed primary WhatsApp credentials file could prevent startup even when the atomic-write backup still contained valid linked-device credentials.
Why This Change Was Made
The repaired branch validates credential JSON at the auth-store owner boundary. When the primary file is malformed and its backup is valid, startup restores the backup atomically; when both are malformed, it preserves the existing failure instead of guessing or deleting user state.
User Impact
WhatsApp can recover automatically from an interrupted or corrupted credential write when the valid backup is available, without requiring a new QR pairing.
Evidence
09b0d55c163fa7a2c800f1344311e40ee6d73724.28742714587.