Skip to content

Commit a4a3818

Browse files
committed
Strip whitespace from URIs in get_file_source_path
Deferred dataset source_uris can contain stray leading/trailing whitespace (e.g. a newline picked up when the URI was pasted into a workflow input). Commit 4f60a2a switched score_url_match from substring to strict prefix matching, so such URIs now score 0 on every file source and materialization fails with "Could not find handler for URI [...]" in the workflow scheduler. Strip the URI once at the top of get_file_source_path so both find_best_match and to_relative_path see the normalized value. This heals already-persisted rows without a data migration.
1 parent d9e498f commit a4a3818

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

lib/galaxy/files/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ def find_best_match(self, url: str) -> Optional[BaseFilesSource]:
199199

200200
def get_file_source_path(self, uri):
201201
"""Parse uri into a FileSource object and a path relative to its base."""
202+
uri = uri.strip()
202203
if "://" not in uri:
203204
raise exceptions.RequestParameterInvalidException(f"Invalid uri [{uri}]")
204205
file_source = self.find_best_match(uri)

test/unit/files/test_posix.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,3 +549,10 @@ def test_score_url_match_requires_prefix():
549549
# Embedded scheme must not match
550550
assert file_source.score_url_match("gxfiles://test1http://evil.com/foo") == 0
551551
assert file_source.score_url_match("http://evil.com/gxfiles://test1/a") == 0
552+
553+
554+
def test_get_file_source_path_strips_whitespace():
555+
file_sources = _configured_file_sources()
556+
resolved = file_sources.get_file_source_path("\ngxfiles://test1/a\n")
557+
assert resolved.file_source is not None
558+
assert resolved.path == "/a"

0 commit comments

Comments
 (0)