Skip to content

fix(memory): handle ENOENT gracefully in readFile#20680

Merged
vignesh07 merged 5 commits into
openclaw:mainfrom
pahdo:fix/memory-readfile-enoent
Feb 20, 2026
Merged

fix(memory): handle ENOENT gracefully in readFile#20680
vignesh07 merged 5 commits into
openclaw:mainfrom
pahdo:fix/memory-readfile-enoent

Conversation

@pahdo

@pahdo pahdo commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • MemoryIndexManager.readFile now catches ENOENT and returns { text: "", path } instead of throwing, so the memory read tool degrades gracefully when a file doesn't exist yet (e.g. a daily log that hasn't been created).
  • Adds an e2e test covering the ENOENT → empty-text path.

Closes #9307

Test plan

  • Existing memory-tool.e2e.test.ts suite passes
  • New "returns empty text without error when file does not exist (ENOENT)" test passes
  • Manual: delete a daily memory log, invoke the read tool — should return empty text, no error

🤖 Generated with Claude Code

Greptile Summary

Changed MemoryIndexManager.readFile to catch ENOENT errors and return { text: "", path } instead of throwing, allowing the memory read tool to degrade gracefully when files don't exist yet (e.g., daily logs that haven't been created)

  • Added try-catch block around fs.lstat call in manager.ts:440-452
  • Returns empty text with path when file is not found, instead of throwing error
  • Added e2e test case to verify ENOENT handling returns empty text without error
  • Existing error handling for other file system errors (permissions, invalid paths) remains unchanged

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The change is a focused error handling improvement with proper test coverage. It follows established ENOENT handling patterns in the codebase, degrades gracefully by returning empty text rather than throwing, and includes an e2e test that validates the new behavior. The modification is minimal and well-contained.
  • No files require special attention

Last reviewed commit: d15ea24

(2/5) Greptile learns from your feedback when you react with thumbs up/down!

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels Feb 19, 2026
@pahdo

pahdo commented Feb 20, 2026

Copy link
Copy Markdown
Contributor Author

Hey @vignesh07 @gumadeiras — this fixes the ENOENT errors from #9307 by handling missing memory files gracefully in readFile instead of throwing.

@vignesh07

Copy link
Copy Markdown
Member

Taking a look.

@openclaw-barnacle openclaw-barnacle Bot added size: S docs Improvements or additions to documentation size: M and removed size: XS size: S labels Feb 20, 2026
@openclaw-barnacle openclaw-barnacle Bot added channel: bluebubbles Channel integration: bluebubbles channel: discord Channel integration: discord channel: googlechat Channel integration: googlechat channel: imessage Channel integration: imessage channel: line Channel integration: line channel: matrix Channel integration: matrix channel: mattermost Channel integration: mattermost channel: msteams Channel integration: msteams labels Feb 20, 2026
@openclaw-barnacle openclaw-barnacle Bot added channel: nextcloud-talk Channel integration: nextcloud-talk channel: nostr Channel integration: nostr channel: signal Channel integration: signal channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: tlon Channel integration: tlon channel: voice-call Channel integration: voice-call channel: whatsapp-web Channel integration: whatsapp-web channel: zalo Channel integration: zalo channel: zalouser Channel integration: zalouser app: android App: android labels Feb 20, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

5 similar comments
@openclaw-barnacle

Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle

Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle

Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle

Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

@openclaw-barnacle

Copy link
Copy Markdown

Closing this PR because it looks dirty (too many unrelated commits). Please recreate the PR from a clean branch.

pahdo and others added 5 commits February 19, 2026 23:20
When a memory file doesn't exist yet (e.g. daily log `2026-02-19.md`),
`readFile` now returns `{ text: "", path }` instead of propagating the
ENOENT error. This prevents noisy error responses from the memory read
tool and aligns with the "graceful degradation" recommendation in openclaw#9307.

Closes openclaw#9307

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@vignesh07 vignesh07 reopened this Feb 20, 2026
@greptile-apps

greptile-apps Bot commented Feb 20, 2026

Copy link
Copy Markdown
Contributor

Too many files changed for review. (846 files found, 100 file limit)

@vignesh07
vignesh07 force-pushed the fix/memory-readfile-enoent branch from 7f75353 to 992d3d5 Compare February 20, 2026 07:29
@openclaw-barnacle openclaw-barnacle Bot removed channel: bluebubbles Channel integration: bluebubbles channel: discord Channel integration: discord channel: googlechat Channel integration: googlechat channel: imessage Channel integration: imessage channel: line Channel integration: line channel: matrix Channel integration: matrix channel: mattermost Channel integration: mattermost channel: msteams Channel integration: msteams channel: nextcloud-talk Channel integration: nextcloud-talk channel: nostr Channel integration: nostr channel: signal Channel integration: signal labels Feb 20, 2026
@vignesh07

Copy link
Copy Markdown
Member

Landed via temp rebase onto main.

  • Gate: pnpm lint && pnpm build && pnpm test
  • Land commit: 992d3d5
  • Merge commit: 083298a

Thanks @pahdo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Memory system file not found errors and sync failures

2 participants