List persisted keys that contain a tilde - #43
Merged
Merged
Conversation
GetKeyFromFileName treated any filename containing '~' as truncated and returned null, so an entry stored under a key such as "backup~1" could be retrieved and cleared but never appeared in GetAllKeysAsync. Truncated names are now recognised by their full shape: at or just under the maximum encoded length, ending in the marker and a 16-digit lowercase hex hash. Fixes #41 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NHprKRwyYopkJnUyhF3KSr
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NHprKRwyYopkJnUyhF3KSr
|
This was referenced Sep 28, 2026
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.



Fixes #41
What changed
PersistenceProviderUtilities.GetKeyFromFileNamereturnednullfor any filename that contained~, because it treated every such name as truncated. As a result, entries stored under keys likebackup~1,~draftora~bcould be retrieved and cleared, butGetAllKeysAsyncnever listed them.A name is now treated as truncated only if it matches the whole shape that
Truncateproduces. The newIsTruncatedNamecheck requires all of the following:MaxEncodedLengthminus the up-to-two charactersTruncatebacks off to avoid splitting a percent-escape)~followed by 16 lowercase hex digitsWhy the encoding was not changed
The issue also suggested adding
~toReservedCharactersso a literal tilde would encode as%7E. I left that out on purpose. It would move every existing tilde key to a new filename.StoreAsync,RetrieveAsyncandExistsAsynclook files up by encoded name, so entries already on disk under a raw~would stop being found by key, and the listing would then report keys thatRetrieveAsynccan't open. Checking the shape fixes the listing and leaves the filenames of existing data unchanged.One ambiguity is not new: a key of 98–100 characters that happens to end in
~plus 16 hex digits looks exactly like a truncated name. It stays hidden from the listing, as it was before this change.Tests
Keys_Containing_A_Tilde_Are_Listedstoresa~b,backup~1and~draftthroughFileSystemPersistenceProviderand asserts thatGetAllKeysAsyncreturns all three.SafeFileName_Roundtrips_Through_Decodingnow also covers tilde keys.SafeFileName_Bounds_Length_And_Stays_Distinctstill passes, so truncated names are still reported as unrecoverable.🤖 Generated with Claude Code
https://claude.ai/code/session_01NHprKRwyYopkJnUyhF3KSr
Generated by Claude Code