Skip to content

fix(memory): compare resolved paths in the delete root guard - #2

Open
dajiaohuang wants to merge 2 commits into
mainfrom
fix/memory-delete-guard-compare-resolved-paths
Open

dajiaohuang wants to merge 2 commits into
mainfrom
fix/memory-delete-guard-compare-resolved-paths

Conversation

@dajiaohuang

Copy link
Copy Markdown
Owner

Fix for anthropics#1906 - compare resolved paths instead of raw command.path to prevent path bypass in delete root guard

When message_start event omits the usage field, the usage is never
initialized. This causes errors later when message_delta tries to
access current_snapshot.usage.output_tokens.

This fix ensures usage is initialized with default values (input_tokens=0,
output_tokens=0) when message_start omits it.
The delete guard was comparing raw command.path against "/memories",
but _validate_path already normalizes and resolves the path. This
allowed variations like /memories/, /memories//, /memories/. to slip
past the guard.

Fix by comparing the resolved full_path against memory_root.resolve()
instead of comparing raw command.path against "/memories".

This fixes both the sync and async delete methods.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant