Repository navigation
Read a stored value its SemanticString type refuses as not found [patch] - #217
Open
matt-edmondson wants to merge 1 commit into
Open
matt-edmondson wants to merge 1 commit into
matt-edmondson wants to merge 1 commit into
Conversation
CredentialSerialization.Deserialize and DeserializeFromString now catch ArgumentException, which a SemanticString property's validating factory throws for a value it refuses. A damaged entry, one another tool wrote, or one saved before a type's validation was tightened now makes TryGet return false instead of throwing, like any other unreadable entry. Fixes #216 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW6R8MN1ipg19Mih4Z3
|
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 #216
What changed
CredentialSerialization.DeserializeandDeserializeFromStringnow also catchArgumentExceptionand returnnull. ASemanticString<T>property's round-trip converter builds its value through the validating factory, which throwsArgumentExceptionwhen the stored value fails validation. That exception used to escape both methods andCredentialCache.TryGet.So an entry that is damaged, was written by another tool, or was saved before a type's validation got stricter now reads as "not found", the same as any other unreadable entry. The app can then ask for the credential again instead of throwing on every
TryGet.Tests
InvalidStoredValueTests(next toUnknownPayloadTests) registers a credential with an[IsBase64]SemanticStringand plants{"$type":...,"Token":"not base64!"}:DeserializeandDeserializeFromStringreturnnull, andTryGetreturnsfalse. Without the fix, all three fail withArgumentException: Cannot convert "not base64!" to Base64Token.Full suite: 107 passed, 5 skipped (native-store and Windows-only tests), 0 failed.
Generated by Claude Code