Repository navigation
Conversation
S3Storage('b', prefix='agents/') stored objects under 'agents//key'
because the constructor appended '/' to a prefix that already ended in
one. Strip it first, as namespace() already does, so the prefix
normalizes to 'agents/' and matches the TypeScript SDK.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
|
Assessment: Approve Correct, minimal fix that brings the Python Review notes
Nice catch while porting #3967 — good that the fix also folds in the leading/duplicate-slash cases. |
9 tasks
This branch has not been deployed
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.
Human Overview
Description
The Python
S3Storageconstructor appended/to the normalized prefix without first stripping a trailing one, so a prefix ending in/produced a double slash in every object key:write("key", ...)therefore storedagents//keyinstead ofagents/key. The constructor now strips the trailing slash first, the same waynamespace()already does. This makes it match the TypeScriptS3Storage, which normalizesprefix: 'agents/'(and'/agents//a/') toagents/(agents/a/).Behavior change for existing data.
S3Storagehas shipped sincepython/v1.48.0, and its own docstring example (and the context offloader's) uses a trailing-slash prefix. Objects already written through a prefix that ends in/live under the double-slash key (agents//...). After this fix, a storage built with the same prefix reads and listsagents/..., so it no longer finds those objects. Nothing is deleted. To keep reading old data, move the objects to the single-slash keys, or construct the storage with the double-slash prefix explicitly until they are migrated. Prefixes without a trailing slash (prefix="agents") are unaffected.Related Issues
None. Found while porting the S3 Vectors search strategy (#3967) to Python.
Documentation PR
None needed.
Type of Change
Bug fix
Testing
New test:
prefix="agents/data/"andprefix="/agents//data//"both store underagents/data/keyand list back askey. It fails on main and passes with the fix.hatch teston storage, session, memory stores and context offloader: 807 passed.hatch fmt --formatterandhatch fmt --linter(ruff + mypy) clean.I ran
hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.