Repository navigation
feat: terrio vsi list/copy/delete/move/sync (gdal vsi parity) - #302
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
Walkthrough
Merge Risk:
|
Code reviewI read the CLI layer, the MCP changes, and the delete, move and sync logic in Bugs
Security
Performance
Quality
CLAUDE.md (AGENTS.md)
Change sizeCompared: the whole PR against main (merge base 5f4a527 to PR head 7c71334)
|
Code reviewI read Bugs
Security
Performance
Quality
CLAUDE.md
Change sizeCompared: the whole PR against main (merge base 2d71f94 to PR head f131b5c)
Sizes use 1 KB = 1024 B. These are file sizes, not line counts. |
Code reviewThis was a partial review. I read the CLI layer, the MCP changes, the CLI tests and the safety, delete and move logic in Bugs
Security
Performance
Quality
CLAUDE.md
Change sizeCompared: the whole PR against main (merge base 2d71f94 to PR head 9619ecb)
Largest changes:
|
Code reviewI read Bugs
Security
Performance
Quality
CLAUDE.md / AGENTS.md
Change sizeCompared: the whole PR against main (merge base 2d71f94 to PR head d56e12e)
|
|
@coderabbitai Please review the latest changes and approve this PR once your actionable findings are addressed. I am continuing to resolve the remaining review comments and CI failures. |
|
|
Code reviewI reviewed the full diff: the core Bugs
Security
Performance
Robustness
Quality and CLAUDE.md
Change sizeCompared with the base branch (merge base e607d5a to PR head 5ed8319).
|
- Browser/WASM listings of s3:// keep the key raw, as native code does: the key is URL-encoded before Api::for_url decodes it once, so s3://bucket/a%20b lists the prefix "a%20b/", not "a b/" (regression s3_keys_are_listed_raw_as_natively). - A 200 page that is not an object-store listing makes read-only discovery (Zarr children) and has_entries (stat) report a store that cannot list, as before; only complete listings for mutations fail (regression a_page_that_is_not_a_listing_fails_only_complete_listings). - Note at the SigV4 payload hash that signed file uploads read the file twice, as docs/cli.md records; alternatives are tracked in #335.
Code reviewBugs
Security
Performance
Quality
CLAUDE.md (AGENTS.md)
Change sizeCompared: the whole PR against main (merge base 040b145 to PR head 62a6d32).
|
- Recursive S3 delete keeps an exact object that coexists with prefix/ children, as GDAL 3.13.3 does and docs/cli.md states: 236b4a3 had started deleting it. compare_vsi_with_gdal.py now reports 25/25 identical again (24/25 before, on the coexisting-object check). - The CLI regression asserts GDAL's behaviour: -r removes x/ and keeps x; deleting x without -r removes it.
Code reviewScope: the full PR (39 files, about 8k added lines). I read the core Bugs
Performance
Security
Quality
CLAUDE.md (AGENTS.md)
Two of my inline attempts were rejected because those lines are not in the PR diff ( Change sizeCompared with the base branch, merge base 040b145 to PR head c2751c1 (the whole PR against
|
- In-memory mounts move to a reserved /vsimem/.terrio-mounts prefix: vsi refuses paths at or below it, and /vsimem listings above it leave mount files out. A user file such as /vsimem/terrio/1/x can no longer overwrite a live mount's file, be deleted when a mount drops, or let delete -r wipe mounts (regressions mounts_are_out_of_reach_of_vsi and mounts_are_reserved_and_left_out_of_listings).
| Node::S3 { bucket, key: key.trim_end_matches('/').to_string() } | ||
| } | ||
| crate::vfs::Location::Url(u) => { | ||
| let (base, query) = u.split_once('?').map_or((u.as_str(), ""), |(b, q)| (b, q)); |
There was a problem hiding this comment.
Bug (medium-low, confidence ~70%): gs:// and az:// keys are parsed as URLs, unlike s3://.
vfs::Location::parse_unarchived turns gs://b/k and az://a/c/k into raw https:// URLs, so Node::parse splits at the first ? (here, line 305) and Api::for_url percent-decodes the prefix (listing.rs lines 121–129). s3:// keys stay raw, and listing names come back as raw keys, so the round trip breaks:
- A listed GCS/Azure name containing
?,#or%XXcan't be passed back tovsi copy/delete. The text after?is taken as a query. - For Azure with
AZURE_STORAGE_SAS_TOKENset,az://acct/c/a?bbecomes…/c/a?b?sv=…, whichNode::parsesplits into base…/c/a, queryb?sv=…. Avsi copy local az://acct/c/a?bwould then overwrite bloba, andvsi delete az://acct/c/a?bwould deletea.
Suggested fix: in Node::parse, handle gs://, /vsigs/, az:// and /vsiaz/ before delegating to vfs, and percent-encode the key the same way the s3:// branch of RemoteLister::new does (uri_encode(key, false)), appending the SAS token separately. Add a regression test with ?, # and %20 in an Azure blob name.
| Api::Url { base: format!("{scheme}://{host}/{bucket}"), prefix: with_slash(&uri_decode(prefix)) } | ||
| } else if lower.ends_with(".blob.core.windows.net") { | ||
| let (container, prefix) = key.split_once('/').unwrap_or((key, "")); | ||
| Api::Azure { base: format!("{scheme}://{host}/{container}"), prefix: with_slash(&uri_decode(prefix)), sas: query.to_string() } |
There was a problem hiding this comment.
This is the other half of the gs:///az:// round-trip issue flagged in vsi.rs. uri_decode(prefix) decodes a raw key, so a Google or Azure key with %20 lists as a b/ while the same spelling on s3:// lists as a%20b/. The s3:// branch in RemoteLister::new encodes the key first to avoid exactly this. The fix belongs at the input boundary (see the comment on vsi.rs:305), so the decode here can remain URL-only for real https:// inputs.
| } | ||
| return Err(Error::Unsupported(message.into())); | ||
| } | ||
| let to = checked_child_target(dst, &e.name, portable)?; |
There was a problem hiding this comment.
Nit (performance): checked_child_target re-canonicalizes the destination root and walks its ancestors for every entry, so a copy of N files costs several extra syscalls per file. The root could be canonicalized once in copy_tree and passed down, with only the per-entry ancestor walk left in the loop. This is minor for typical trees and is not a correctness issue.
| if data.len() as u64 > MAX_HTML_BYTES { | ||
| return Err(Error::InvalidData("HTTP directory index exceeds 4 MiB".into())); | ||
| } | ||
| if !String::from_utf8_lossy(&data).to_ascii_lowercase().contains("<a ") { |
There was a problem hiding this comment.
Minor inconsistency: this check requires a literal "<a " (space), but parse_html_index accepts any ASCII whitespace after <a. A page with <a\nhref=…> markup is therefore rejected as "not a listable HTML directory index" even though the parser would read it. The same check exists in RemoteLister::feed. Both could share one helper that accepts whitespace. Also, lowercasing the whole 4 MiB body just for this check is avoidable.
| pub(crate) fn listing_api(dir: &Directory) -> Api { | ||
| match dir { | ||
| Directory::S3 { bucket, prefix } => { | ||
| let prefix = if prefix.is_empty() { String::new() } else { format!("{}/", prefix.trim_end_matches('/')) }; |
There was a problem hiding this comment.
Nit (duplication): this rebuilds the same trailing-slash prefix logic as with_slash in vsi/listing.rs. Making with_slash pub(crate) and calling it here would keep one definition.
Code reviewI reviewed the PR statically from the staged diff and the working tree. I did not build or run the tests. The PR is large, so this is a sampled read of the core paths, not an exhaustive line-by-line audit. Bugs
Quality
Performance
Security
CLAUDE.md / AGENTS.md
I did not verify the PR's stated test results, and I did not run Change sizeCompared with the base branch: the whole PR against
Largest changes:
|
* perf(vsi): cut remote request and I/O costs deferred from #302 - Recursive S3 deletion sends up to 1000 keys per DeleteObjects request (POST ?delete, quiet mode, Content-MD5), reporting the first key the service failed to delete. Services without it, and keys XML cannot carry, get one DELETE per key, as before. - Signed S3 uploads of local files up to 8 MiB read them once, into memory; uploads staged through a temporary file are hashed as they are staged. The signature still covers the payload (no UNSIGNED-PAYLOAD). - Copying, synchronizing or describing a plain HTTP URL without a trailing slash requests one byte first; a response typed other than HTML is a file, without the index probe. Listings and URLs ending with a slash fetch the index page first, as before. - The HTTP requests of one vsi operation share one ureq agent, so its connections and TLS sessions, including writes and listing pages. - Remote archive members are read through one cached reader per operation instead of opening one (and fetching a first block) each. - /vsimem/ moves re-key the shared bytes, and /vsimem/ archives and file reads use them in place, without copies. Part of #335. * fix(vsi): fail DeleteObjects errors, keep key order, hash only signed staging DeleteObjects falls back to single deletes only when the service answers 400, 405 or 501 (or a success without a DeleteResult); other statuses are errors. Keys XML cannot carry are deleted between the batches around them, keeping the key order. Staged uploads are hashed only when they will be signed. * docs(testing): update the DeleteObjects regression count * fix(vsi): keep write-error hints for DeleteObjects, narrow its fallback Only 405, 501 and a 400 whose code is NotImplemented or MethodNotAllowed fall back to one DELETE per key, logged with TERRIO_HTTP_LOG; other statuses go through the ordinary write-error path, with its missing-credentials hint. Document batch-level failure and ordering, and that a typed object named without its slash is a file. * refactor(vsi): name the operation scope, escape delete keys once Rename HtmlCacheScope to OperationScope and document what it scopes. DeleteObjects batches keep each key's XML text instead of escaping it twice, and only 405 and 501 among the remaining statuses fall back. * fix(vsi): delete S3 markers after the objects; slash before the query Directory markers go in requests of their own, sent once every object is deleted, so a failed batch no longer removes the markers above the objects it left. A URL whose path ends with a slash before its query is probed as an index first. * fix(vsi): report DeleteObjects failure counts as lower bounds The DeleteObjects reply is read up to 1 MiB, so with long keys the count of failed keys can undercount. Word it as "at least N", as the first failing key is always reported. Add regression coverage for two paths: a 400 MalformedXML must fail the delete rather than fall back to one DELETE per key, and a bare ?delete subresource must be signed as "delete=". Rewrap the S3 deletion paragraph in docs/cli.md and list the new check in docs/testing.md. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Applied by the claude-autofix workflow. --------- Co-authored-by: giswqs <5016453+giswqs@users.noreply.github.com>
Adds VSI file management through Rust, CLI/MCP, Python and JavaScript/WebAssembly. Part of #289.
Behavior
Validation
In a local environment with GDAL 3.13.3: 58 focused Rust VSI tests, nine CLI tests, five Python tests, nine current release-WASM/Node VSI tests, an optimized CLI build, workspace Clippy and changed-file pre-commit pass. Strict registered VSI conformance under Python -S runs without osgeo/numpy and gives 25/25 comparisons identical: listings, metadata, real-file bytes, copy/sync/delete behavior, local S3 emulation, remote ZIP queries and refusal cases.
Regressions cover encoded space/percent/slash prefixes, missing/../child containment, dot-segment deletion before mutation, portable upload names, invalid ZIP dates, CP437 names, FIFO refusal without blocking, preservation of special destinations, browser stream cancellation and HTML/XML size limits. Nonrecursive tar sync creates each S3 directory marker once for 100 nested members. A killed comparison with empty output now records a nonempty error; four harness tests pass. A legacy ZIP fixture lists café.tif as Python zipfile does and extracts its exact payload; GDAL emits raw non-UTF-8 name bytes for that case.
Earlier measured transfer behavior remains documented: an 8 MiB stored ZIP-member copy takes 131 requests instead of 515 with the same received bytes; ZIP listing takes four requests/32,885 bytes. Native S3 fixture uploads take 10 requests versus GDAL's 20. Integration with main includes #303 and passes 672 core tests (one ignored), the full CLI suite, 14 Python VSI/query tests and ten current release-WASM/Node VSI/query tests. Vector dataset and raster query APIs are preserved.
Scope and limits
Remote writes require host credentials/permissions; browser remote writes and signed S3 requests are unavailable. MCP uses the existing host/client permission model and destructive tool annotations. Ownership and source mutation during copy-delete moves remain caller responsibilities. Non-UTF-8 local names and unsupported links/special entries are refused when they cannot be represented or copied faithfully; metadata timestamps and Unicode filename normalization have the documented limits. Operation errors may leave partial remote work; sync deletion is fail-fast. These commands do not add archive writing or SOZip creation.