Repository navigation
fix(operations): map edit_note write failures to WRITE_FAILED - #116
Merged
Merged
Conversation
An fs write failure inside `edit_note` (disk full, permission lost,
locked file) escaped `FsVaultWriter` as a bare Node `Error`, which
`toToolErrorResponse` renders through its code-less branch — a client
branching on error codes got nothing to branch on, in violation of
ADR-0003. The same failure through `set_property` already yielded
`WRITE_FAILED`.
Wrap both `writeFile` calls in a `writeRaw` helper that maps failures to
`ToolHandlerError('WRITE_FAILED', …)`, matching
`FsVaultProvider.editFrontmatter`. Also give `createNote`'s
both-identifiers-missing guard a code, so the provider contract does not
rely on the tool-level XOR shielding it.
Closes #113
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
An fs write failure inside
edit_note(disk full, permission lost, locked file) escapedFsVaultWriteras a bare NodeErrorwith nocode.toToolErrorResponserenders such an error through its plain{ message }branch, so a client branching on error codes got nothing to branch on — a direct ADR-0003 violation. The identical failure throughset_propertyalready yieldedWRITE_FAILED.Changes
FsVaultWriter— bothwriteFilecalls now go through awriteRawhelper that maps failures toToolHandlerError('WRITE_FAILED', …)withdetails.path, mirroringFsVaultProvider.editFrontmatter.FsVaultProvider.createNote— the both-identifiers-missing guard threw a code-lessnew Error(...). It now throwsINVALID_ARGUMENTviainvalidArgument, so the provider contract does not rely on the tool-level XOR shielding it.Tests
Five new assertions, each verified to fail against the unpatched source:
replaceInNoteandreplaceFullBodymap an injected failingwriteFiletoWRITE_FAILED(ENOSPC / EACCES).edit_note-level cases drive the realFsVaultWriterthroughregisterTool(...).handler(...)and assert the client-visible payload carriescode: 'WRITE_FAILED'— covering the mapping and the rendering together.createNote({})now asserts the code and field instead of only the message string.npm test(1292 passing),npm run lint, andnpm run typecheckall pass.Closes #113
🤖 Generated with Claude Code