-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Description
Summary
- The unified
Pathdesign is solid across local and remote backends, but a few areas need hardening and clearer guidance:- Windows invalid characters in
path_to_localcan still surface and break file operations. - Constructor semantics between
parseandFrom<&str>/childare easy to misuse. - S3 keys with “weird” segments (
//,./..) are deliberately unsupported; this should be documented or optionally relaxed.
- Windows invalid characters in
Current Behavior
- Core implementation in
fusio/src/path/mod.rsandfusio/src/path/parts.rs. - Delimiter is
/everywhere; segments percent-encode reserved/unsafe chars. - Local:
Path::from_filesystem_path→file://URL → percent-decoded once → validatedPath.path_to_local(&Path)builds afile:///...URL and decodes toPathBuf. On Windows, only subsequent colons:are remapped to%3A(the firstC:is preserved).
- S3:
- Object URL path uses strict encoding; list uses encoded
prefixquery parameter. Path::parserejects empty segments and./...
- Object URL path uses strict encoding; list uses encoded
Problems / Risks
- Windows invalid characters:
path_to_localonly special-cases:, but Windows forbids< > : " / \\ | ? *and has trailing dot/space rules. These can survive conversion and cause open/create failures.
- Constructor semantics surprise:
From<&str>/FromIterator/childencode and normalize (empty segments are dropped), butparseonly validates and rejects empty/./... The same input string can yield different outcomes depending on the constructor.
- S3 key edge cases:
- S3 allows keys with
//,./.., or literal%.Path::parserejects some of these by design, which is safe but should be explicitly documented. Some ingestion workflows may need a “relaxed” mode.
- S3 allows keys with
- Round-tripping:
- Local → Path → local on Windows is only partially stable (colons handled), but other invalid characters may not map predictably.
- Minor:
Error::Canonicalizevariant is declared but not used.
Proposed Improvements
-
Windows hardening
- Expand
path_to_local(Windows) to percent-encode additional invalid characters per segment:< > : " / \\ | ? *. - Preserve the drive
C:prefix, continue to encode subsequent colons in the rest of the path. - Keep trailing dot/space encoded so underlying FS operations succeed.
- Add clear comments on why encoding is applied at this boundary to preserve
Pathsemantics while keeping local FS operations valid.
- Expand
-
Constructor clarity
- Document and illustrate intended usage:
- Use
Path::from,from_iter, andchildfor constructing portable paths from application strings (handles encoding). - Use
Path::parsefor external/raw sources (URL paths, S3 keys) to avoid double-encoding; list the validation rules (no empty segments,./..forbidden).
- Use
- Consider adding
Path::from_os_str_lossy(non-wasm) for ergonomic local construction.
- Document and illustrate intended usage:
-
S3 edge cases
- Document that
Path::parserejects keys with./..segments or//. Clarify this is a safety/portability choice. - Optionally add a clearly-named escape hatch (e.g.,
Path::parse_relaxedorPath::from_raw_key_unchecked) for ingestion scenarios that must handle arbitrary keys, with warnings about local portability.
- Document that
-
API polish
- Add
try_to_local_path()returning a structured error on unsafe Windows cases; optionallyto_local_path_lossy()to force-encode and always succeed. - Either wire in canonicalization or remove the unused
Canonicalizeerror variant. - Optionally rename
from_url_pathto a name that signals one-time decode + validation, or document it clearly.
- Add
-
CI/tests
- Add Windows unit tests for:
- Invalid chars mapping in
path_to_localand round-trip viafrom_filesystem_path. - Drive-letter paths (
C:\\foo\\bar), and a UNC sample if supported.
- Invalid chars mapping in
- Add tests clarifying constructor differences and S3 encoding behavior (including
%in keys). - Option: add a minimal Windows CI job that runs the
pathmodule tests only.
- Add Windows unit tests for:
Acceptance Criteria
- Windows:
path_to_localmaps all invalid filename characters safely; creating/opening files with those characters (encoded) works. - Round-trip tests pass on Windows for typical and edge-case names.
- Documentation:
- Clear guidance on
parsevsfrom/child, with examples. - S3 edge cases documented, with an optional relaxed constructor if implemented.
- Clear guidance on
- API:
try_to_local_path()(and/orto_local_path_lossy()) added with documented semantics, or decision documented.Canonicalizevariant either used or removed.
- CI: Windows job executes
pathtests successfully.
Affected Code
fusio/src/path/mod.rs(path_to_local, docs forPathAPI)fusio/src/path/parts.rs(docs forPathPartencoding)- S3:
fusio/src/impls/remotes/aws/{fs.rs,s3.rs,credential.rs,multipart_upload.rs}(docs only) - Tests:
fusio/src/path/mod.rstests; new Windows-specific tests
Backwards Compatibility
- Changes are mostly additive and documentation-driven.
- Windows
path_to_localbehavior expands encoding; paths with invalid chars will now map to different on-disk names than before (more reliable). Note in changelog and consider a feature flag if needed.
Open Questions
- Do we want a “relaxed” parse for S3 ingestion? If yes, how should it interact with local FS (likely not supported → documented)?
- Should
From<&str>keep silently dropping empty segments, or do we add a strict constructor to avoid surprises?
Checklist
- Expand Windows invalid-char handling in
path_to_local - Add Windows unit tests for invalid chars and round-trip
- Clarify
parsevsfrom/childin docs with examples - Document S3 key restrictions; optionally add “relaxed” constructor
- Add
try_to_local_path()orto_local_path_lossy()and document - Use or remove
Error::Canonicalize - Add a minimal Windows CI job for
pathtests
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers