Skip to content

config: fix silent failures and misleading log in config recovery#62665

Closed
pruthvishetty wants to merge 1 commit intoopenclaw:mainfrom
pruthvishetty:fix/config-recovery-silent-failures
Closed

config: fix silent failures and misleading log in config recovery#62665
pruthvishetty wants to merge 1 commit intoopenclaw:mainfrom
pruthvishetty:fix/config-recovery-silent-failures

Conversation

@pruthvishetty
Copy link
Copy Markdown

Summary

  • Fix misleading log message: maybeRecoverSuspiciousConfigRead and its sync variant logged "Config auto-restored from backup" even when the copyFile restore actually failed. The message now reflects the actual outcome (auto-restored vs backup restore failed).
  • Add diagnostic logging to empty catch blocks: Six catch {} blocks in the config health tracking and recovery pipeline now emit logger.warn() with the error message, making failures visible in logs instead of silently swallowing them.

Affected catch blocks

Function Issue
writeConfigHealthState / Sync Health state writes failed silently, losing config health tracking
persistClobberedConfigSnapshot / Sync Clobbered config snapshots failed to persist with no diagnostic output
maybeRecoverSuspiciousConfigRead / Sync Backup restore failures were swallowed; log claimed success regardless

What is NOT changed

The following catch {} blocks are intentionally left as-is — they handle expected conditions (file not found on first run, optional JSON parse fallbacks):

  • readConfigHealthState / Sync — health state file may not exist yet
  • Inner json5.parse in readConfigFingerprintForPath / Sync — deliberate fallback to empty parsed object
  • Outer catch in readConfigFingerprintForPath / Sync — target path may not exist

Test plan

  • Existing io.observe-recovery.test.ts suite passes (3/3 tests green)
  • No new dependencies or imports added
  • Behavioral change is limited to log output; recovery control flow is unchanged
  • Verified via pnpm test src/config/io.observe-recovery.test.ts

[AI-assisted]

🤖 Generated with Claude Code

… in config recovery

Replace empty catch blocks in io.observe-recovery.ts with diagnostic
logger.warn() calls so failures in config health tracking, clobbered
snapshot persistence, and backup restoration are visible in logs.

Fix misleading 'Config auto-restored from backup' warning that fired
even when the copyFile restore actually failed — the message now
reflects the actual outcome.
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 7, 2026

Greptile Summary

Adds diagnostic logger.warn() to six previously empty catch {} blocks in the config health tracking and recovery pipeline, and fixes a misleading log message in maybeRecoverSuspiciousConfigRead/Sync that reported success even when the copyFile restore threw an error. Behavioral control flow is unchanged; only log output is affected.

Confidence Score: 5/5

This PR is safe to merge; all changes are limited to log output with no control-flow impact.

All findings are P2 or lower. The fixes are accurate, well-scoped, and match the PR description. No new dependencies, no behavioral regressions, and the existing test suite passes.

No files require special attention.

Reviews (1): Last reviewed commit: "config: log diagnostic warnings instead ..." | Re-trigger Greptile

@clawsweeper
Copy link
Copy Markdown
Contributor

clawsweeper Bot commented Apr 30, 2026

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close as duplicate/superseded. Current main still has the config restore false-success bug, but #70515 is an open, more complete implementation for the same remaining work; this PR's logging-only patch would still leave audit and caller state misleading on failed restores.

So I’m closing this here and keeping the remaining discussion on the canonical linked item.

Review details

Best possible solution:

Use #70515 or an equivalent canonical patch that keeps restore-failure logs, audit validity/error fields, and async/sync regression tests aligned, then close the non-canonical overlapping branch.

Do we have a high-confidence way to reproduce the issue?

Yes. A high-confidence reproduction path is to inject failing copyFile and copyFileSync calls into maybeRecoverSuspiciousConfigRead; current main swallows the error, logs success, and records valid: true, while #70515 adds tests for that exact path.

Is this the best way to solve the issue?

No. The logging-only approach is not the best fix because it reports failure in the log while leaving the audit record and returned recovery result in a success shape; the narrower maintainable answer is the structured audit-and-test approach in #70515.

Security review:

Security review cleared: The diff is limited to config recovery logging with no dependency, workflow, lockfile, package, publishing, secret-handling, or external code execution changes.

What I checked:

Likely related people:

  • steipete: GitHub path history shows repeated authored work on the central config recovery and audit files, including critical config clobber recovery, invalid gateway config recovery, shared observe recovery helpers, and audit record fixes. (role: introduced behavior and primary config recovery/audit maintainer; confidence: high; commits: 7b2c9a6fa3d3, ffb1628727fd, 83801c49f7a3; files: src/config/io.observe-recovery.ts, src/config/io.observe-recovery.test.ts, src/config/io.audit.ts)
  • jalehman: Recent main history shows adjacent config recovery-policy work in the same observe recovery module and tests. (role: recent adjacent maintainer; confidence: medium; commits: f369939fedd5; files: src/config/io.observe-recovery.ts, src/config/io.observe-recovery.test.ts)

Codex review notes: model gpt-5.5, reasoning high; reviewed against ad7fa6c38774.

@clawsweeper clawsweeper Bot closed this Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant