Skip to content

fix(plugins): a GRIB byte range a plugin command asked for lands for it (#2428) - #3003

Merged
elpidioassinaturas merged 2 commits into
opengeos:mainfrom
elpidioassinaturas:fix/bytes-range-retry
Nov 27, 2026
Merged

elpidioassinaturas merged 2 commits into
opengeos:mainfrom
elpidioassinaturas:fix/bytes-range-retry

Conversation

@elpidioassinaturas

@elpidioassinaturas elpidioassinaturas commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A plugin command that asks layer.addUrl for a byte range of a GRIB file ("bytes", #2669) waits 10 minutes in the desktop app before it runs again, though its download landed in seconds.

Why: the app downloads a range under the address with the range marked in it (ranged_address, …grb#rustgis-range=first-last), and the layer it adds carries that address. asked_by compares it with the address the command asked for, which has no mark, so the download is never matched to its request. The command waits out REQUEST_WAIT and runs again only then. The command line downloads at once, so it never shows there.

Fix: in asked_by (crates/engine/src/cmd/plugin_fetch.rs), a request with "bytes" also matches the address with exactly that range marked. Another range of the same file is still another request, and a request without "bytes" doesn't match a marked address.

Found with the BrasilData plugin's new forecast command, which reads the 6-hourly records of CPTEC/INPE's BAM model (about 4 MB each, out of 1.6 GB files).

Testing

  • New test a_byte_range_lands_under_its_marked_address: the marked address of the range asked for is what was asked; another range, and a request without a range, aren't.
  • cargo test -p rustgis-engine --lib fetch:: (23 tests pass), clippy, cargo fmt --check and cargo xtask test-hygiene. The rest of the workspace and the wasm build are left to CI.
  • In the desktop app, built from this branch, with a separate profile: a plugin command asking for 4 ranges of BAM's files ran again as soon as they landed and finished in under a minute. With 0.8.0, the same command was still waiting after the 3 minutes I watched, its 4 layers already added.

UI evidence

No visible UI change.

Related issue

Part of #2428.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Ranged downloads now match front-end URLs when their byte range matches the original request. Requests with different ranges or no requested range are not treated as matches.

…it (opengeos#2428)

The desktop app downloads a range under its marked address (`ranged_address`), so `asked_by` never matched it: the command waited out its 10 minutes before running again. A range asked for now matches the address with that range marked, and only that one.

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

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

asked_by now matches URLs marked with the requested byte range. It accepts ranges with exactly two unsigned integers and also handles trimmed URLs. Tests cover matching and non-matching cases.

Changes: Byte-range request matching

Layer / File(s) Summary
Extract and match byte ranges
crates/engine/src/cmd/plugin_fetch.rs
asked_by extracts a range from a bytes array with exactly two unsigned integers. It matches direct URLs or URLs marked with that range, including trimmed addresses. Tests cover matching ranges, different ranges, and marked URLs when no range was requested.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

Suggested reviewers: mavrick-f, giswqs, deniial00

Merge Risk: Minimal · up to b5c71

This change makes plugin commands that request a GRIB byte range stop waiting out the full request interval once the range has downloaded. No actionable merge risk remains; the wider workspace and wasm build still need to pass in CI.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the fix (a GRIB byte range requested by a plugin command now lands for that command) and the affected area (plugins). It matches the change in asked_by, which matches ranged downloads …
Description check Passed The description covers the required template sections: Summary (explains the cause, the fix, and the affected function), Testing (names the new test, the cargo test command, clippy, fmt, and a desktop…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the fix (a GRIB byte range requested by a plugin command now lands for that command) and the affected area (plugins). It matches the change in asked_by, which matches ranged downloads to their request. The title uses the conventional fix(scope) prefix and includes the PR number, and it is a single sentence. It is somewhat long at 79 characters and could be shorter, but it is specific and relevant.

Full details: Description check

Explanation

The description covers the required template sections: Summary (explains the cause, the fix, and the affected function), Testing (names the new test, the cargo test command, clippy, fmt, and a desktop-app trial), UI evidence (states 'No visible UI change.' as the template requires), and Related issue (Part of #2428). The description is thorough and matches the template. The template's Related issue placeholder is filled with 'Part of #2428', which satisfies the template's example format.

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 checks the bytes in flight
Two numbers make the range just right
Trimmed links pass the matching test
A different range is laid to rest
No range asked? No mark will do
The plugin finds the download true

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: 8ee680f7-d113-4009-8c41-6a625ee0ff10
Commits

Reviewing files that changed from the base of the PR and between 66c8856 and b5c71f0.

Files selected for processing: 1

  • crates/engine/src/cmd/plugin_fetch.rs

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

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

Copy link
Copy Markdown
Contributor

Code review

Reviewed the one changed file, crates/engine/src/cmd/plugin_fetch.rs, with the surrounding code it relies on: layer.rs (byte_range, ranged_address), policy/downloads.rs (ranged_claim), and the app's download path in ui-egui/src/lib.rs. There are no prior review threads, so none were left alone.

Bugs

  • Trailing whitespace in the asked URL still misses the match (confidence: medium, not run). asked_by trims both URLs, so the marked address it expects has no space before #rustgis-range=. The app builds the marked address from the raw URL (ui-egui/src/lib.rs:6122, :6176), and ranged_claim does the same. For "…/model.grb ", the app's marked address keeps the space, so the 10-minute wait the PR fixes would remain for that input. Posted inline at plugin_fetch.rs:573 (I did not include the suggested code block in the comment; the fix is to compare against ranged_address of the raw URL).

Security

  • None found. The new branch only matches the exact marked form of the asked address, so it does not widen which downloads a command's wait accepts.

Performance

  • None found.

Quality (nits, not posted inline)

  • The closure's given binding shadows the outer let given in asked_by. Renaming one would make it easier to read.
  • The new test covers the leading-space and other-range cases, but not a trailing space or the layer.addDownload path that the doc comment mentions.

AGENTS.md

  • None found. The new code is not cfg-gated, and ranged_address is plain string building, so it builds for wasm. byte_range refuses ranges in the browser, so the new path is not reachable there.

Twins checked

  • layer.addUrl and layer.addDownload: holds accepts both, and the change sits in the shared matcher, so both are covered.
  • ranged_claim in policy/downloads.rs: it has the same raw-versus-trimmed issue (see Bugs).
  • The other asked_by callers, at plugin_fetch.rs:634 and :725: they inherit the change, which is intended.
  • The app's download path (ui-egui/src/lib.rs:6122, :6176): it uses the raw URL, which is the root of the Bugs finding.

Change size

Compared with main (merge base 6810fba to PR head 43f9dad), using KB = 1024 bytes.

Measure Value
Files changed 1 (0 added, 1 modified, 0 removed, 0 renamed)
Size before 88.3 KB
Size after 89.8 KB
Total size change +1.5 KB
Path Before After Change
crates/engine/src/cmd/plugin_fetch.rs 88.3 KB 89.8 KB +1.5 KB

@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

📖 Docs preview

Commit b5c71f0 from a fork built, but isn't published until a maintainer adds the preview label (once per commit).

elpidioassinaturas pushed a commit to elpidioassinaturas/BrasilData that referenced this pull request Nov 26, 2026
Na janela do RustGIS 0.8.0, um comando de plugin que pede um trecho de
um arquivo GRIB só roda de novo 10 minutos depois, embora os registros
cheguem em segundos (opengeos/RustGIS#3003 corrige). O aviso da
previsão do BAM e a ajuda do formulário dizem agora o nome das camadas
dos registros e que basta rodar o comando de novo quando elas
aparecerem: ele usa os que já chegaram.

Testes: 276; smoke sem falhas no rustgis-cli 0.5.0 e 0.8.0; BAM de 1 dia
em Viçosa em 4 s no CLI 0.8.0. O aviso novo não foi visto na janela.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the app marks

The desktop app marks a GRIB range on the address as the plugin gave it, spaces and
all, so a request for "…/model.grb " landed under "…/model.grb #rustgis-range=…"
and wasn't matched: its command still waited the ten minutes.

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

Copy link
Copy Markdown
Contributor

Code review

Overall the change looks correct. I found no bugs. The one prior concern on this PR (a trailing-space address producing a marked address the match misses) is answered by b5c71f0. I checked both paths: the desktop app builds the marked address from the raw p["url"] (crates/ui-egui/src/lib.rs:6176), and the leave-downloads path queues a trimmed URL (crates/engine/src/cmd/layer.rs:5588-5589). The two candidates in asked_by cover both.

Bugs

  • None confirmed.
  • Low confidence (about 25%): the first disjunct, u.map(str::trim) == given, still matches a plain (unmarked) landing for a request with "bytes". This predates the PR, and the app never lands a plain address for a ranged request, so I don't think it is reachable. Tightening it would make the "a request with bytes only matches its marked address" rule explicit.

Security

  • None found. The new bytes parsing uses as_u64 and zip, and Value indexing doesn't panic.

Performance

  • None. The added work is a few string allocations per match, which is negligible.

Quality

  • Posted inline on plugin_fetch.rs:555: asked_by re-parses "bytes" instead of reusing layer::byte_range, which validates it. The two agree today, but they could drift.
  • Nit, not posted: the closure at line 577 packs two candidate trims and a marked-address comparison into one expression. Splitting it into a named helper would read better.

AGENTS.md

  • None. The change adds no commands, schema or layers. The wasm32 path is unaffected because ranged_address isn't cfg-gated and is already used by policy/downloads.rs.

Twins checked

  • policy/downloads.rs::ranged_claim (lines 19-23) builds the same marked address through byte_range and ranged_address, so it is consistent with the fix.
  • same_request (plugin_fetch.rs:795) already trims the URL.
  • The other asked_by callers (lines 613, 638, 729) share the fix.
  • layer.addDownload doesn't read "bytes" (add_download never calls byte_range), so there is nothing to match there.
  • The CLI path (add_url_range) and the app path (ui-egui add_url) are both covered by the reasoning above.

Already raised (left alone)

  • 1 earlier concern (the trailing-space thread) was already answered and fixed in b5c71f0, so I did not post it again.

Change size

Compared with the base branch: the whole PR against main (merge base 6810fba to PR head b5c71f0).

Measure Value
Files changed 1 (added 0, modified 1, removed 0, renamed 0)
Size before 88.3 KB
Size after 90.4 KB
Total size change +2.2 KB
Path Before After Change
crates/engine/src/cmd/plugin_fetch.rs 88.3 KB 90.4 KB +2.2 KB

@elpidioassinaturas
elpidioassinaturas marked this pull request as ready for review November 27, 2026 01:42
Comment thread crates/engine/src/cmd/plugin_fetch.rs Resolved
Comment thread crates/engine/src/cmd/plugin_fetch.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

This PR makes asked_by (crates/engine/src/cmd/plugin_fetch.rs) match a landed GRIB byte-range download to the request that asked for it, by comparing against the address with the range marked in it. I found no bugs or security issues. The trimmed-address bug raised in an earlier thread is fixed in b5c71f0, and I confirmed the fix by reading the code.

Bugs: None found. I traced the trimmed and untrimmed URL paths against ranged_claim (policy/downloads.rs) and the app's ranged_address call, and they agree.

Security: None found. The new code only compares strings and reads numbers. Hostile input is handled without panics.

Performance: None found.

Quality:

  • plugin_fetch.rs:575: With "bytes" asked, the plain-address arm still matches a landing under the bare address, so a whole-file download could count as the range's answer. The desktop app doesn't seem to produce this today, so confidence is low. (Inline comment posted.)
  • plugin_fetch.rs:577: Nits, grouped. The closure line is about 130 columns, u is shadowed inside it, and params["url"] on line 572 indexes instead of using get(). (Inline comment posted.)

AGENTS.md: No rule violations found. The wasm build is unaffected: ranged_address and cache::RANGE are not cfg-gated, and byte_range already refuses ranges in the browser. The tests use assert! with fixed expected values, which fits test-hygiene.

Prior reviews: I left 1 earlier concern alone. It is the open thread on line 555 saying asked_by re-parses "bytes" instead of using layer::byte_range. The code still does that, and the thread has no answer. I did not re-post the trimmed-address thread, because the author answered it and the code now handles it.

Change size

Compared with the base branch, covering the whole PR (merge base 6810fba to head b5c71f0).

Files changed Added Modified Removed Renamed Size before Size after Total change
1 0 1 0 0 88.3 KB 90.4 KB +2.2 KB
Path Size before Size after Size change
crates/engine/src/cmd/plugin_fetch.rs 88.3 KB 90.4 KB +2.2 KB

@elpidioassinaturas
elpidioassinaturas added this pull request to the merge queue Nov 27, 2026
Merged via the queue into opengeos:main with commit 2624b18 Nov 27, 2026
31 checks passed
@elpidioassinaturas
elpidioassinaturas deleted the fix/bytes-range-retry branch November 27, 2026 16:05
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.

2 participants