fix: percent-encode storage resource paths on the wire (#124) - #125
Merged
andrii-novikov merged 6 commits intoAug 26, 2026
Conversation
DIAL Core parses every resource path (in the URL and in JSON bodies such as
sourceUrl/destinationUrl) as a percent-encoded URL. A raw reserved character
(space, #, ?, [, ...) either got truncated by urlparse or reached Core
unencoded, making 'new URI(...)' throw and Core answer 404/500.
Add percent_encode_resource_url() plus DialStorageResourceMixin
.get_encoded_api_path(), which decode-then-encode each segment so decoded
('my file.txt') and already-encoded ('my%20file.txt', as returned by the API)
inputs converge without double-encoding. Apply it across files (upload,
download, delete, move_to, copy_to, get_metadata), the shared metadata.get
(also covers conversations and direct low-level calls), prompts, and
resource_permissions.grant.
Drop the _prepare_file_download wrapper; encode the url and decode the returned filename directly in the shared (files-only) _prepare_download_request.
andrii-novikov
force-pushed
the
fix/124-encode-storage-resource-paths
branch
from
July 27, 2026 15:08
d83b4f5 to
c6b6848
Compare
andrii-novikov
requested review from
VinShurik,
adubovik and
korotaav48
and removed request for
adubovik
July 28, 2026 07:46
adubovik
requested changes
Jul 31, 2026
Move URL encoding into safe_parse_storage_resource so get_api_path encodes automatically, drop the now-redundant get_encoded_api_path, rename percent_encode_resource_url to the private _percent_encode_relative_url, widen mixin helpers to accept str | PurePosixPath, and extract a shared _grant_body helper for ResourcePermissions.
adubovik
approved these changes
Aug 26, 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.
Applicable issues
Description of changes
DIAL Core parses every storage resource path — both in the request URL (
upload/download/delete/get_metadata) and in JSON body fields (sourceUrl/destinationUrlfor move/copy,urlfor permission grants) — as a percent-encoded path (each segment is URL-decoded viaUrlUtil.decodePath, which runsnew URI(segment)).A raw reserved character in a filename therefore broke things:
#/?were truncated by the client'surlparseinget_api_pathbefore the request was even built → wrong path → 404.[/]/ space and friends reached Core unencoded →new URI(...)throwsURISyntaxException, which Core wraps in a bareRuntimeException→ 500.The URL-slot ops only worked by accident (httpx encodes the URL path on the wire); the body-slot ops (
move_to/copy_to) had nothing encoding them at all.Fix:
percent_encode_resource_url()(stateless helper) andDialStorageResourceMixin.get_encoded_api_path()inhelpers/storage_resource.py.my file.txt) and an already-encoded one (my%20file.txt, as returned by the API) converge to the same wire form without double-encoding. Absolute URLs (always encoded by the API) pass through untouched.files.py— upload, download, delete, move_to, copy_to, get_metadatametadata.py— the sharedget(covers conversations and direct low-levelclient.metadata.get(...)calls)prompts.py— save, get, delete, get_metadataresource_permissions.py—grantbody urlsVerification:
files.get_metadataand low-levelmetadata.get.nox -s formatclean.Notes:
application/deployments/model/toolset) were left unchanged — they interpolate deployment/model names, not storage paths, and conventionally contain no reserved characters.%sequence can't be expressed from a decoded path (extremely rare).Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.