Normalize percent-encoded URIs used as workspace dict keys#594
Merged
tombh merged 1 commit intoopenlawlibrary:mainfrom Mar 6, 2026
Merged
Normalize percent-encoded URIs used as workspace dict keys#594tombh merged 1 commit intoopenlawlibrary:mainfrom
tombh merged 1 commit intoopenlawlibrary:mainfrom
Conversation
tombh
requested changes
Mar 4, 2026
Collaborator
tombh
left a comment
There was a problem hiding this comment.
This looks good, I think you just need to add feat: to the front of the commit meesage.
14c6408 to
29d04f5
Compare
Contributor
Author
Updated the commit message, thanks! |
URIs used as dictionary keys in the Workspace class were stored and looked up without normalization. If a client sent a percent-encoded URI (e.g. file:///C%3A/foo) on one request and a decoded form (file:///C:/foo) on another, lookups would fail with KeyError since the raw strings differ. Apply urllib.parse.unquote to all URIs before using them as keys in _text_documents, _notebook_documents, _cell_in_notebook, and _folders dictionaries. This ensures equivalent URIs that differ only in percent encoding map to the same entry.
29d04f5 to
01fc44e
Compare
tombh
approved these changes
Mar 6, 2026
Collaborator
|
Thank you |
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.
Problem
URIs used as dictionary keys in the
Workspaceclass are stored and looked up without normalization. If a client sends a percent-encoded URI (e.g.,file:///C%3A/foo) on one request and a decoded form (file:///C:/foo) on another, lookups fail withKeyErrorbecause the raw strings differ despite referring to the same resource.This is the same class of issue as microsoft/pyright#11293, where percent-encoded Windows drive letter colons (
%3A) caused path resolution failures.Fix
Apply
urllib.parse.unquoteto all URIs before using them as dictionary keys in:_text_documents_notebook_documents_cell_in_notebook_foldersThis ensures equivalent URIs that differ only in percent encoding consistently map to the same entry.
Tests
Added 7 new tests covering:
All 26 tests pass (19 existing + 7 new).