fix: encode file paths for DIAL Core requests#457
Open
andrii-novikov wants to merge 1 commit into
Open
Conversation
DIAL Core 500s (URISyntaxException: Illegal character in path) when file URLs containing spaces or parens reach it verbatim - most visibly on copy/move, whose ops/resource JSON body bypasses HTTP-client URL encoding entirely. Establish a URL contract on DialFileService: decoded 'files/...' URLs in and out; percent-encoding is an internal egress concern. An idempotent quote(unquote(...)) accepts both spellings, and list_folder decodes Core's encoded item URLs so the file tools keep matching human-readable globs with no encoding awareness. StateHolder's file-cache key gets the same normalization so every cache user (DialFileService, FileLoaderService) shares one entry per file regardless of spelling. Fixes #447
Collaborator
|
Shouldn't that logic belong to |
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
Copying a context file whose name contains spaces or parens (e.g.
Uno-Rules-PDF-Official-Rules-unorules.org_ (1).pdf) fails with a DIAL Core 500 (java.net.URISyntaxException: Illegal character in path). File URLs flow to Core verbatim:aidial_clientperforms no path encoding, andcopy_to/move_toput the URLs in anops/resource/*JSON body that the HTTP client never touches, so nothing on the wire ever encodes them.Key changes:
DialFileServicenow owns a URL contract: decoded (human-readable)files/...URLs in and out; percent-encoding is an internal egress concern. A private_encodehelper (quote(unquote(url), safe="/")) is applied immediately before everyaidial_clientcall — metadata lookup, download, upload, delete, and both source and destination of copy/move (the exact path Quick app 2.0 with switched on Files tools can not perform actions with pdf Context files from Organization or Shared with me #447 dies on). Unquote-then-quote makes it idempotent, so already-encoded and decoded inputs both land on the same encoded spelling;safe="/"preserves the trailing/that folder metadata lookups rely on. Accepted edge case (documented at the helper): a filename literally containing a valid%XXsequence is indistinguishable from its encoded form and gets normalized.list_folderbuildsFolderEntry.urlfromunquote(item.url)(Core returns encoded URLs), so the file tools (list/find/searchglob matching, display paths) operate on decoded names with zero encoding awareness in the tooling layer.StateHolderfile-cache keys get the same normalization, so the encoded and decoded spellings of one file share a single cache entry across every cache user (DialFileServiceandFileLoaderService/DialDownloaderpopulate the same per-request cache); invalidation on write/delete/move can no longer miss an entry stored under the other spelling.Tests: egress encoding for spaces/parens, idempotence (no double-encoding), trailing-slash preservation, copy/move encoding both URLs, decoded
list_folderoutput, cache hits and invalidation across spellings, decoded multipart filename on upload, and afindtool test proving a human-readable glob matches a space-bearing filename.make lintand the full unit suite (1628 tests) pass.Checklist
[ ] Design documented is updated/created and approved by the team (if applicable)(bug fix, no design doc)[ ] Documentation is updated/created (if applicable)(no user-facing config or behavior contract change)[ ] App schema changes are backward compatible, or breaking changes are documented with a migration guide(no config model changes; schema check green)By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.