Skip to content

fix: encode file paths for DIAL Core requests#457

Open
andrii-novikov wants to merge 1 commit into
developmentfrom
fix/447-encode-file-paths
Open

fix: encode file paths for DIAL Core requests#457
andrii-novikov wants to merge 1 commit into
developmentfrom
fix/447-encode-file-paths

Conversation

@andrii-novikov

Copy link
Copy Markdown
Collaborator

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_client performs no path encoding, and copy_to/move_to put the URLs in an ops/resource/* JSON body that the HTTP client never touches, so nothing on the wire ever encodes them.

Key changes:

  • DialFileService now owns a URL contract: decoded (human-readable) files/... URLs in and out; percent-encoding is an internal egress concern. A private _encode helper (quote(unquote(url), safe="/")) is applied immediately before every aidial_client call — 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 %XX sequence is indistinguishable from its encoded form and gets normalized.
  • Ingress is decoded: list_folder builds FolderEntry.url from unquote(item.url) (Core returns encoded URLs), so the file tools (list/find/search glob matching, display paths) operate on decoded names with zero encoding awareness in the tooling layer.
  • StateHolder file-cache keys get the same normalization, so the encoded and decoded spellings of one file share a single cache entry across every cache user (DialFileService and FileLoaderService/DialDownloader populate 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_folder output, cache hits and invalidation across spellings, decoded multipart filename on upload, and a find tool test proving a human-readable glob matches a space-bearing filename. make lint and the full unit suite (1628 tests) pass.

Checklist

  • Title of the pull request follows Conventional Commits specification
  • [ ] 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)
  • Changes are tested on review environment
  • [ ] App schema changes are backward compatible, or breaking changes are documented with a migration guide (no config model changes; schema check green)
  • Integration tests pass

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

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
@ypldan

ypldan commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Shouldn't that logic belong to aidial-client library?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Quick app 2.0 with switched on Files tools can not perform actions with pdf Context files from Organization or Shared with me

2 participants