Feature/gallery upload routing rsdev 1192#56
Merged
Conversation
When a file is uploaded to a Gallery folder in the wrong media-type section, the RSpace API rejects it and the client raised an opaque ApiError. Re-raise as GallerySectionMismatch naming the folder's section (and the file's guessed media type) with the original error preserved. Detection is reactive: the enriched error is only produced after a real server rejection of a folder-targeted upload, so the best-effort filename classifier can never block an otherwise-valid upload. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add an on_mismatch policy to GalleryFilesystem: "raise" (default, the clear error from the previous change) or "reroute", which on a section mismatch re-uploads with no folderId so the server places the file in the correct section's inbox. The policy is set filesystem-wide in the constructor (so it also applies to generic PyFilesystem operations that call upload/openbin) and can be overridden per upload() call. upload() now returns a Placement describing where the file landed (global id, section, human-readable path, and whether it was rerouted). Reroutes are logged at INFO. Document the behaviour in the usage guide. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…EV-1192) Galaxy's RSpace file source monkeypatches eln_client.upload_file with a wrapper that captures the response and returns None, then calls GalleryFilesystem.upload via super(). Change 2 started consuming upload_file's return value to build a Placement, which crashed on that None with AttributeError, breaking every Galaxy->RSpace export. Make _placement tolerate a non-dict/None response and make the best-effort folder-lookup helpers never raise, so a successful upload can never fail during Placement construction. Direct callers still receive a full Placement. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The changes look ok to me. Thanks a lot @tilorspace |
tilorspace
marked this pull request as ready for review
July 15, 2026 15:53
The error-message classifier wrongly treated "Documents" as the catch-all and used invented audio/video/chemistry extensions. Per the Gallery docs and rspace-web (FolderManagerImpl.getApiUploadTargetFolder / MediaUtils), the catch-all is "Miscellaneous"; "Documents" is a fixed extension set. Rebuild the extension->section table from the documented lists, default unlisted types to Miscellaneous, and phrase the mismatch message accordingly. Placement is unaffected: reroute stays server-authoritative (upload with no folderId), so this only improves the wording of the raised error. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Author
|
Missed one category; should be fully covered now with the latest commit. |
tilorspace
added a commit
that referenced
this pull request
Jul 16, 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.
Summary
Makes the RSpace Gallery a friendlier upload target for
GalleryFilesystem(PyFilesystem) by handling the Gallery's media-type section rule instead of
failing opaquely. Three separable changes plus a Galaxy-compatibility fix.
Jira: RSDEV-1192
Background
The Gallery is split into media-type sections:
Images,Audios,Videos,Documents,Chemistry, andMiscellaneous. Each specialised section acceptsonly its own file types (
Documentsis a fixed set: doc, docx, rtf, pdf, odt,ods, odp, txt, ppt, pptx, xls, xlsx, csv, pps, md);
Miscellaneousis thecatch-all for anything else. The server (
FolderManagerImpl.getApiUploadTargetFolder)classifies a file from its name and, for a folder-targeted gallery upload,
requires the folder to be the matching section folder or a subfolder of it,
otherwise it rejects the upload.
Previously
GalleryFilesystem.upload()passed the folder straight through, so asection mismatch surfaced as an opaque
ApiErrorand the file was lost.What changed (four commits, reviewable in order)
Clearer error (
8bb9e2a) — when a folder-targeted upload is rejected,re-raise a
GallerySectionMismatchnaming the folder's section (and thefile's guessed media type), with the original API error preserved. Detection
is reactive: it only enriches after a real server rejection, so the
best-effort filename classifier can never block a valid upload.
Opt-in auto-reroute (
7e8e07e) — add anon_mismatchpolicy:"raise"(default) or
"reroute". On reroute, the file is re-uploaded with nofolderIdso the server places it in the correct section's inbox. The policyis set filesystem-wide in the constructor (so it also applies to generic
PyFilesystem operations that call
upload/openbin) and can be overriddenper
upload()call.upload()now returns aPlacementdescribing where thefile landed (global id, section, human-readable path,
reroutedflag).Galaxy-compatibility fix (
6cb1f60) — Galaxy's RSpace file sourcemonkeypatches
eln_client.upload_filewith a wrapper that returnsNone,then calls our
upload()viasuper(). Commit 2 began consuming that returnvalue to build the
Placement, which crashed onNone._placementnowtolerates a non-dict/
Noneresponse and the folder-lookup helpers neverraise, so a successful upload can never fail during
Placementconstruction.Correct classifier (
0b086a5) — the error-message classifier wronglytreated
Documentsas the catch-all and used invented audio/video/chemistryextensions. Rebuilt the extension→section table from the Gallery docs and
rspace-web (
MediaUtils), defaulting unlisted types toMiscellaneous.Placement is unaffected (reroute stays server-authoritative); this only
improves the wording of the raised error.
API / behaviour
Default policy is
"raise", so existing behaviour is preserved apart from theclearer exception type (a subclass of the previous
ApiError).Backwards compatibility
upload()signatures remain call-compatible (new params arekeyword/defaulted).
GallerySectionMismatchsubclassesApiError, so existingexcept ApiErrorhandlers still catch it.
lib/galaxy/files/sources/rspace.py,PR #20167 on
dev): the reroute is inert for Galaxy (default policy) and thefix in commit 3 keeps its export path working. Recommend re-confirming against
the specific Galaxy release branch deployed.
Testing
rspace_client/tests/eln_fs_test.py— 19 unit tests pass, covering bothpolicies (constructor + per-call), the media classifier (including the
Miscellaneous catch-all), policy validation, the no-folder passthrough,
success/mismatch/reroute placements, and a regression reproducing Galaxy's
upload_file-returns-Nonemonkeypatch.Docs
docs/usage-guide.mddocuments the section rule,on_mismatch, andPlacement.Follow-ups (not in this PR)
upload_filemonkeypatch and readPlacement.file_global_iddirectly, now that
upload()returns it.