Skip to content

fix(engine): stac.addCube adds its tile layers from a plugin command in the app - #2422

Merged
Mavrick-F merged 2 commits into
opengeos:mainfrom
elpidioassinaturas:fix/2418-addcube-plugin
Nov 20, 2026
Merged

Mavrick-F merged 2 commits into
opengeos:mainfrom
elpidioassinaturas:fix/2418-addcube-plugin

Conversation

@elpidioassinaturas

@elpidioassinaturas elpidioassinaturas commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Problem

A plugin command that runs stac.addCube in the desktop app fails for every collection, even when the files are valid cloud-optimised GeoTIFFs:

https://…/S2-16D_V2_033027_20250525_NDVI.tif: not a cloud-optimised GeoTIFF read in place; a data cube needs those

The same call works in rustgis-cli (for files whose addresses name a GeoTIFF, as STAC APIs' do). cube.open with a STAC entry of cube.catalog goes through stac.addCube and fails the same way.

Cause

A plugin's command in the app runs with leave_downloads set. In that mode layer::add_url returns s.request_url(…) for any remote address before it reaches the cloud-optimised GeoTIFF branch, so the "cube": true file stac::add_cube asks for comes back as a download left to the app ("pending": true), not a tile layer. add_cube then finds no tile layer at the returned index and reports the file as not cloud-optimised.

Fix

  • crates/engine/src/cmd/layer.rs: under leave_downloads, a remote GeoTIFF with "cube": true (named .tif/.tiff, or "cog"; not "as": "scan" or "whole") is added with add_cog directly, its header unread, as the browser build already does. A tile layer reads its tiles in place on later frames, so nothing waits on the command's frame (add_cog already skips the header probe under leave_downloads). Every other remote address is still left to the app exactly as before.
  • crates/engine/src/cmd/stac.rs: add_cube tells a pending answer apart (a cube file whose address names no GeoTIFF, left to the app) and says so, instead of "not a cloud-optimised GeoTIFF". What it added is taken back as for any other failure, and the queued request goes with the failed command.

Surfaces

Only plugin commands run by the desktop app change: they run through Session::run_leaving_downloads, the one place leave_downloads is set. The command line, scripts and the Assistant/MCP tools run commands that wait and already took the add_cog path; the browser build takes it too (wasm32 branch, untouched). No command description, parameter or i18n text changes. The cube's tile layers are one undo step, as from the command line.

A cube file that turns out not to be cloud-optimised is added unprobed (a plugin command can't wait for its header on the frame, as in the browser). Its header's error is then said as the map draws it: the desktop map view notifies tile-layer errors (mapview.rs, session.notify(error, true)), and a GeoTIFF export lists it among the tile layers that failed. The test covers that side too.

Limit, unchanged by this PR: a cube file whose address names no GeoTIFF (no .tif/.tiff, no "cog") is still left to the app in a plugin command, and stac.addCube refuses it with the new message. The command line reads such a file by probing its header (is_unnamed_url), which a plugin command can't wait for on the frame; reading it would need that probe off the frame, a separate change. Real STAC sources name their files (the Brazil Data Cube's …_NDVI.tif, Earth Search's ….tif).

Test

a_stac_data_cube_from_a_plugin_command_in_the_app: a session with leave_downloads set runs stac.addCube against a STAC API served locally (items on two grid tiles, COGs served by range). It checks that two tile layers are added with their per-date files and range, that nothing is left to the app, and that the time slider gets the two dates and steps through them. cube.open (open_entry with a STAC entry pointed at the same API) adds the same layers. A cube file whose address names no GeoTIFF gets the new message, with nothing kept. A cube file that is a plain (stripped) GeoTIFF is added, its header read fails with "not a cloud-optimised GeoTIFF", and a GeoTIFF export of the view says so.

On main the test fails with the error from the issue (…/a1.tif: not a cloud-optimised GeoTIFF read in place; a data cube needs those); with the fix it passes. cargo test -p rustgis-engine --lib: 1802 passed. cargo clippy -p rustgis-engine --all-targets -- -D warnings and cargo fmt --check are clean.

Closes #2418

🤖 Generated with Claude Code

Summary by CodeRabbit

Summary

  • New Features
    • Supported TIFF and COG assets can be added directly as tile layers in cube workflows instead of being deferred for app download.
  • Bug Fixes
    • STAC cube requests with unsupported assets now show a clear error identifying the file address and required format, and restore the map to its previous state without retaining partial changes.

…in the app (opengeos#2418)

A plugin's command in the desktop app runs with leave_downloads set, and
layer.addUrl left every remote address to the app, the data cube's
GeoTIFFs too: no tile layer came, and stac.addCube said the file was "not
a cloud-optimised GeoTIFF read in place". A "cube": true GeoTIFF is now
added as a tile layer at once (its tiles are read in place on later
frames, nothing waits), as the command line and the browser do.
stac.addCube also tells a file left to the app to download apart from
one that isn't cloud-optimised.

Closes opengeos#2418

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Desktop cube requests now add qualifying remote COGs as tile layers instead of deferring them to the app. If an asset remains pending, add_cube restores saved map state and returns an error that identifies the fragment-free file URL.

Changes: STAC cube loading

Layer / File(s) Summary
Add cube COGs in place
crates/engine/src/cmd/layer.rs
When cube is enabled and the URL is a TIFF or cog is true, add_url immediately adds a tile layer unless the request is a scan or has whole set.
Handle pending cube assets
crates/engine/src/cmd/stac.rs, crates/engine/src/tests.rs
add_cube restores saved tiles and layers and returns an error when add_url returns pending: true. Validation and errors use the fragment-free file URL. Tests cover cube entry points, date navigation, pending assets, and non-COG handling.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

Suggested reviewers: giswqs, mavrick-f

Merge Risk: Minimal · up to be845

Desktop plugin commands can now add valid remote COG cubes as tile layers, and pending assets get a clear error with the map state restored. No actionable merge-blocking risk was found.

Pre-merge checks: Passed 2 · Inconclusive 2

Failed Failed checks: 2 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive Issue #2418 requires that a remote cube GeoTIFF under leave_downloads be added as a tile layer, not left to the app, and that a pending answer not be reported as 'not a cloud-optimised GeoTIFF'. The s… Provide readable source evidence for the add_url hunk in crates/engine/src/cmd/layer.rs (merge base to head) showing the leave_downloads branch for remote GeoTIFFs with "cube": true calls add_cog, and confirm the test in crates/engine/src/t…
Out of Scope Changes check Inconclusive The verified stac.rs hunks are related to the issue. They change add_cube's pending handling, the file-name comparison, and the not-COG error text. The layer.rs hunk (+9 lines, per the summary) and th… Provide readable source evidence for the layer.rs add_url hunk and the tests.rs additions (merge base to head). Confirm that the add_url change applies only to remote GeoTIFFs with "cube": true under leave_downloads and leaves other remote …
Passed Passed checks: 2 passed

Check name Status Explanation
Title check Passed The title names the main change: stac.addCube adding its tile layers from a plugin command in the desktop app. It matches the changeset, which routes remote cube GeoTIFFs to add_cog under leave_downlo…
Description check Passed The description follows the template sections (Summary, Testing, UI evidence, Related issue). Summary explains the problem, cause, fix, and surfaces affected. Testing names the new test, the results o…
Full details: Title check

Explanation

The title names the main change: stac.addCube adding its tile layers from a plugin command in the desktop app. It matches the changeset, which routes remote cube GeoTIFFs to add_cog under leave_downloads and fixes add_cube's pending-answer handling. The title uses the 'fix(engine)' prefix and is 79 characters, slightly long but specific and on topic.

Full details: Description check

Explanation

The description follows the template sections (Summary, Testing, UI evidence, Related issue). Summary explains the problem, cause, fix, and surfaces affected. Testing names the new test, the results on main and with the fix, and the cargo commands run. The UI evidence section is not filled in with the template's 'No visible UI change.' line; the text is kept, so that section is present. Related issue is filled in with 'Closes #2418'. The description is complete and specific, with no required section missing.

Full details: Linked Issues check

Explanation

Issue #2418 requires that a remote cube GeoTIFF under leave_downloads be added as a tile layer, not left to the app, and that a pending answer not be reported as 'not a cloud-optimised GeoTIFF'. The stac.rs diff (merge base to head) is readable. It adds a check for "pending": true in add_cube. That check returns a new error and calls undo(s), so the pending case no longer gets the misleading message. This meets the second requirement. The first requirement depends on the layer.rs change in add_url, which the requested diff could not read: the blob diff was unavailable, and a file read of the head layer.rs was truncated before the add_url branch. The change is known only from the PR summary, which says the cube GeoTIFF branch now calls add_cog under leave_downloads. The test a_stac_data_cube_from_a_plugin_command_in_the_app in tests.rs was also not read. Its result is reported only by the author and the summary.

Resolution

Provide readable source evidence for the add_url hunk in crates/engine/src/cmd/layer.rs (merge base to head) showing the leave_downloads branch for remote GeoTIFFs with "cube": true calls add_cog, and confirm the test in crates/engine/src/tests.rs runs stac.addCube with leave_downloads set and checks tile layers and time-slider dates. Re-run the assessment with that evidence.

Full details: Out of Scope Changes check

Explanation

The verified stac.rs hunks are related to the issue. They change add_cube's pending handling, the file-name comparison, and the not-COG error text. The layer.rs hunk (+9 lines, per the summary) and the test in tests.rs (+97 lines, per the summary) could not be read. The summary describes both as limited to the cube path, and the PR description states the same. No unrelated change is demonstrated. The layer.rs change cannot be checked for scope, so no PASS is given.

Resolution

Provide readable source evidence for the layer.rs add_url hunk and the tests.rs additions (merge base to head). Confirm that the add_url change applies only to remote GeoTIFFs with "cube": true under leave_downloads and leaves other remote addresses unchanged. Re-run the assessment with that evidence.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit sees a COG take flight,
A tile appears, its path just right.
The dates step on through time,
While layers line up in rhyme.
If pending, state rolls back in place,
And an error names the file with grace.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: ee26004c-9da9-45dc-b829-d8fa90273aeb
Commits

Reviewing files that changed from the base of the PR and between a02d2a9 and be845c2.

Files selected for processing: 3

  • crates/engine/src/cmd/layer.rs
  • crates/engine/src/cmd/stac.rs
  • crates/engine/src/tests.rs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

@elpidioassinaturas

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Comment thread crates/engine/src/cmd/layer.rs Resolved
Comment thread crates/engine/src/cmd/layer.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I read the diff, the surrounding code in layer.rs, stac.rs and tiles/cog.rs, and the notice path in engine/src/lib.rs. I did not run the tests (no shell here), so the new test's result is unverified.

Bugs

  • Under leave_downloads, a non-COG remote .tif with "cube": true is added with its header unread. add_cog_with returns Ok, so stac.addCube reports success. A later header failure lands in State::Failed, which notice_landed_rasters does not read. This could leave an empty tile layer with no notice. Confidence: medium. Posted inline at layer.rs:4433.
  • The new branch has no http/https check, unlike the dated-address branch above it, so a local .tif with "cube": true now takes add_cog where it used to be a download request. Confidence: low. Posted inline at layer.rs:4432.

Security

  • No issues found. The check_reach and mark_url_reach gates run before the new branch.

Performance

  • No issues found. The new branch adds one non-blocking add_cog per file.

Quality

  • Nits, left for the release quality pass: stac.rs uses file.unwrap_or(first) where split always yields a value, and layer.rs mixes b(p, …) with super::b(p, …) in neighbouring lines.

AGENTS.md

  • The PR body does not say which surfaces it reaches (CLI, browser, Assistant/MCP tool descriptions, plugins, undo). The "Reach every surface" rule asks for that statement.
  • The lossy non-COG case has no test. "Test both ways" asks for a test on each side.

Earlier concerns: there were no prior review threads, so nothing was left out as already raised.

Change size

Compared: the whole PR against main (merge base 0e9e6cd to PR head a02d2a9).

Files changed Added Modified Removed Renamed Size before Size after Total change
3 0 3 0 0 3.51 MB 3.52 MB +5.2 KB
Path Before After Change
crates/engine/src/tests.rs 3.09 MB 3.09 MB +4.2 KB
crates/engine/src/cmd/stac.rs 83.2 KB 83.8 KB +553 B
crates/engine/src/cmd/layer.rs 348.4 KB 348.9 KB +513 B

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-2422/
Web app https://preview.rustgis.app/pr-2422/app/
Commit be845c2

GitHub Pages takes a minute or two to publish a new commit.

…pengeos#2418)

- Test the other side: a cube file that is a plain (stripped) GeoTIFF is
  added unprobed from a plugin command, its header read fails with "not
  a cloud-optimised GeoTIFF", and a GeoTIFF export of the view says so,
  as the desktop map view does for any tile layer's error.
- Say in the comment why the branch needs no web check (web_address
  refuses other addresses above it), and use `b` throughout.
- add_cube keeps the file's address as a &str instead of an Option.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread crates/engine/src/cmd/stac.rs Resolved
Comment thread crates/engine/src/cmd/layer.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I found no crash, silent-loss or wasm-build problems in the changed lines. Two inline comments are posted: an address leak in the new error (low confidence) and a limit on unnamed-address COGs in the app path (medium). I could not run the build or tests here, so the PR's own claim that the test passes is unverified by me.

Bugs

  • Incomplete fix (medium): under leave_downloads, a cube GeoTIFF whose address has no file name (for example …/files/u1) is still refused. The CLI probes such addresses and reads them. The new message also says "(.tif)", which points the user at the wrong fix. Posted inline at layer.rs:4433. It is not a regression, since the old code refused it too.

Security

  • Possible address leak (low): the new add_cube error includes file without redaction, and file keeps any query string. Signed STAC hrefs could expose a token. The old message had the same problem. Posted inline at stac.rs:1272 with a suggestion that redacts only the message.

Performance

  • None found. The new branch uses cog::info (non-blocking), so it adds no wait on the UI thread.

Quality

  • The test ignores the export result (let _ = flat.run("share.exportMap", …), tests.rs ~26795). If the export fails for another reason, the failure is opaque. Minor, left for the release quality pass.

AGENTS.md

  • Checked: the new code is inside cfg(not(wasm32)), so the wasm build is unaffected. The web-address check runs before the new branch (layer.rs:4356), so local paths never reach it. Reach and undo are covered in the PR body, and the test covers the pending-refusal rollback.
  • request_url gates downloads by policy. The new branch skips it, but plugin commands are gated by their declared network/files permissions at command ingress (policy/decide.rs:156-166). I found no bypass.

Earlier concerns left alone: 2

  • Silent failure of a non-COG cube file (layer.rs:4435). Answered by the author. The map view does notify each new tile error (mapview.rs:1767-1771), and a test covers the export side.
  • Local path reaching the new branch (layer.rs:4432). Answered. web_address runs first at layer.rs:4356.

Change size

Compared with main (merge base 0e9e6cd to PR head be845c2).

Measure Value
Files changed 3 (0 added, 3 modified, 0 removed, 0 renamed)
Size before 3.51 MB
Size after 3.52 MB
Total size change +7.2 KB
Path Before After Change
crates/engine/src/tests.rs 3.09 MB 3.10 MB +6.3 KB
crates/engine/src/cmd/layer.rs 348.3 KB 348.9 KB +671 B
crates/engine/src/cmd/stac.rs 83.2 KB 83.6 KB +429 B

@elpidioassinaturas
elpidioassinaturas marked this pull request as ready for review November 19, 2026 01:45
@github-actions

Copy link
Copy Markdown
Contributor

Code review

No new findings. I read the three changed files, the surrounding code, and the earlier review threads, and checked the following against the code:

  • Cube branch in layer.rs: runs only under leave_downloads, only for a non-scan, non-whole remote GeoTIFF with "cube": true. The web_address check (layer.rs:4356) runs before it, so local paths can't reach it. add_cog is called with probed = false, and probed && !s.leave_downloads (layer.rs:4887) keeps the header read off the frame.
  • Silent failure of an unprobed header: the author's reply holds. Tile-layer errors reach the user through app.session.notify(error, true) in mapview.rs:1550-1552, 1767 and 1829.
  • Pending check in stac.rs: the undo at stac.rs:1270 is the local closure from stac.rs:1250, so it does not undo unrelated history. Option vs &str comparison (Some(file)) is equivalent to the old code.
  • Wasm: the new branch is inside the existing #[cfg(not(target_arch = "wasm32"))] block, so no desktop-only code leaks into the browser build.
  • Security: I considered whether the new branch skips the download queue (enqueue_url) that would otherwise apply to a plugin's remote cube file. The plugin already has authority to make the app fetch that URL, and the non-plugin path already reads remote COGs in place, so I'm not raising it.

I did not run the test suite or clippy; this review was read-only.

Earlier threads (4 total, all left alone):

  • stac.rs:1272, query string in the new pending message (unresolved, still applies). The PR's new message still includes file unredacted. The suggested crate::sources::redact(file) fix is still the right one, and it is the most useful thread to act on.
  • layer.rs:4433, an unnamed cube address (no file extension) is refused in the app but read by the CLI (unresolved, still applies). The test does pin the refusal, but the PR body doesn't name it as a limit, and the new (.tif) hint points users at the wrong fix for such addresses.
  • layer.rs:4435, a silent failure for an unprobed header (resolved; the author's answer holds, see above).
  • layer.rs:4432, a web-address check (resolved; web_address(url)? at layer.rs:4356 covers it).

Change size

Compared: the whole PR against main (merge base 0e9e6cd to PR head be845c2).

Measure Value
Files changed 3 (added 0, modified 3, removed 0, renamed 0)
Size before 3.51 MB
Size after 3.52 MB
Total size change +7.4 KB
Path Before After Change
crates/engine/src/tests.rs 3.09 MB 3.10 MB +6.3 KB
crates/engine/src/cmd/layer.rs 348.4 KB 349.0 KB +671 B
crates/engine/src/cmd/stac.rs 83.2 KB 83.6 KB +429 B

@Mavrick-F
Mavrick-F added this pull request to the merge queue Nov 20, 2026
Merged via the queue into opengeos:main with commit ddc7ffd Nov 20, 2026
27 checks passed
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.

[Bug]: stac.addCube from a plugin command in the desktop app says a valid COG "is not a cloud-optimised GeoTIFF"

3 participants