Skip to content

fix(services): retry failed ArcGIS pages smaller, add a where filter, and point layer addresses to their service (#1998) - #2144

Merged
Mavrick-F merged 2 commits into
opengeos:mainfrom
Mavrick-F:fix/service-page-retries
Nov 15, 2026
Merged

Mavrick-F merged 2 commits into
opengeos:mainfrom
Mavrick-F:fix/service-page-retries

Conversation

@Mavrick-F

@Mavrick-F Mavrick-F commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Summary

Three ArcGIS service gaps from the trial in #1998:

  • A failed page wasn't retried smaller. FEMA's NFHL flood zones (MapServer layer 28) fail on full pages of large polygons, well below the 2,000 records the layer advertises. A page that fails with a server error, a timeout or a reset connection is now retried at the same offset with half the records, down to one feature; later pages keep the size that worked. A notice counts the retried requests, and a page that still fails names the layer and offset. A Retry-After answer isn't treated as a size problem. While a page can still shrink, each request gets a 10-second limit inside the existing overall wait, so a stuck page falls back to smaller ones rather than using up the read. Cancel and the read limits are unchanged.
  • No filter on service.add. An optional where parameter passes a SQL where clause to an ArcGIS feature layer's query. It's kept through paging, retries and the GeoJSON fallback. Without it the query is 1=1 as before, and a clause the server rejects gives an error saying so. Kind of change: any maintainer, an optional parameter.
  • A layer address was refused without a hint. Listing …/MapServer/21 now says it's layer 21 and to list …/MapServer with service.layers, then add it with that url and layer 21.

The one-minute read limit stays as it is (#829).

Testing

  • arcgis_pages_retry_at_smaller_sizes (failed before the change): GeoJSON and protocol-buffer pages failing first or later read every feature in order at a smaller size, with the notice only when a retry happened; retries are bounded.
  • Existing HTTP fixture server: the where clause reaches the query and survives paging; the default is unchanged; a rejected clause errors.
  • a_layer_address_says_which_service_to_list.
  • cargo test -p rustgis-data ogc::tests, -p rustgis-engine arcgis_, -p rustgis-ui-egui serviceui::tests; wasm check of rustgis-web.
  • cargo xtask ci on the fork's CI.

No live network in tests.

UI evidence

No visible UI change.

Related issue

Part of #1998 (the ArcGIS layers line).

Summary by CodeRabbit

  • New Features
    • ArcGIS feature layers now support optional filters when added. Filters apply across paginated results and can be combined with a bounding box.
    • Failed feature-page requests may be retried with smaller pages, down to one feature. Notices report when smaller-page retries occur.
  • Bug Fixes
    • ArcGIS layer-address errors now provide clearer guidance for finding and adding layers.
    • Feature-page requests can time out individually, allowing eligible pages to be retried while preserving features already received.

@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

ArcGIS service handling now supports feature-layer where clauses, gives guidance for numeric layer addresses, retries eligible page failures with smaller requests, and applies page-specific timeouts to feature-page fetching.

Changes: ArcGIS service queries and paging

Layer / File(s) Summary
Layer addressing and filtered service.add queries
crates/data/src/ogc.rs, crates/engine/src/cmd/service.rs, crates/engine/src/tests.rs, docs/user-guide/data-formats.md
Numeric layer-address errors now identify the parent service and layer ID. service.add accepts a non-empty where clause for feature layers, applies it to ArcGIS query URLs, and rejects unsupported clauses. Tests and documentation cover filtering, bounding boxes, and layer-address guidance.
Smaller-page retries and failure reporting
crates/data/src/ogc.rs, docs/user-guide/data-formats.md
Eligible ArcGIS page failures retry at the same offset with halved page sizes. PBF fallback restores the original size. Failure messages include sanitized layer and offset details, and completion notes report smaller-page retries. Tests cover retry behavior and exclusions.
Page-specific timeout handling
crates/data/src/ogc.rs, crates/engine/src/cmd/service.rs, crates/ui-egui/src/serviceui.rs
Pages::page_timeout() returns a timeout for offset pages larger than one. Command and UI feature-page fetches use that timeout when available; description fetches retain their separate timeout handling.

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

Change: Bug fix

Possibly related issues

  • Issue 1998: The changes implement its listed ArcGIS gaps: smaller-page retries, where filtering in service.add, and guidance for numeric layer addresses. The issue’s read-limit note is outside these changes.

Suggested reviewers: jgregoriorincon, giswqs

Merge Risk: Low · up to c4d54

ArcGIS paging now retries failed pages at smaller sizes and supports a where filter. In one rare fallback case the note about how many retries occurred can be missing, while the truncation warning and the data stay correct. This is safe to merge with owner awareness.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the three changes in the PR: smaller retries for failed ArcGIS pages, a new where filter for service.add, and clearer layer-address guidance. The raw summary and objectives confirm all…
Description check Passed The description follows the template's Summary, Testing, UI evidence, and Related issue sections. The Summary explains the three changes and their rationale. The Testing section lists specific tests a…
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 three changes in the PR: smaller retries for failed ArcGIS pages, a new where filter for service.add, and clearer layer-address guidance. The raw summary and objectives confirm all three. The title is long, though, and it uses a conventional-commit prefix and a PR number, which adds noise. It still describes the main changes accurately.

Full details: Description check

Explanation

The description follows the template's Summary, Testing, UI evidence, and Related issue sections. The Summary explains the three changes and their rationale. The Testing section lists specific tests and commands. The UI evidence section correctly says there is no visible UI change. The Related issue section says the PR is part of #1998. The description does not give a full 'Closes' link, but the template allows 'Part of #456' style references, so this is acceptable.

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 query stream
Small pages hop through errors’ seam
A filtered clause joins the ride
Timeout waits keep pages inside
The layer path is clear to see
Then clover waits for you and me

Comment thread crates/data/src/ogc.rs

/// Leaves time for smaller-page retries within a blocking reader's total deadline.
/// A single-feature page cannot shrink, so it keeps the reader's remaining wait.
pub fn page_timeout(&self) -> Option<std::time::Duration> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Behaviour/performance (medium-low confidence): the new 10-second per-page limit applies to every page while size > 1, and the size never grows back. Take a slow but working server with 2,000-record pages that answers one page in 12 s. Before this change, that page finished inside the one-minute read. Now it halves to 1,000, and every later page in the layer stays at 1,000 records, so the layer needs about twice the requests. That adds latency and can push a layer that finished in under a minute into "the pages timed out".

The PR description states that smaller sizes persist and the 10-second limit is new, which is a deliberate trade-off. It is worth confirming it is what is wanted, and documenting the 10-second per-page limit in docs/user-guide/data-formats.md, which does not mention it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A deliberate trade-off: a page slower than 10 seconds costs one abandoned attempt, then the read carries on at the size that answers. Keeping the smaller size avoids paying that attempt again on every page. Letting the size grow back, and naming the 10-second limit in the guide, are left for the release quality pass.

Comment thread crates/data/src/ogc.rs
&& !matches!(self.phase, Phase::Offsets { pbf: true, .. })
&& query_value(&self.url, "where").is_some_and(|w| !w.eq_ignore_ascii_case("1%3D1") && w != "1=1")
{
return Step::Failed(self.page_failure(&format!("the server rejected the query with its where clause: {error}")));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low confidence (wording/accuracy): any HTTP 400 on a page with a non-default where is reported as "the server rejected the query with its where clause", even when the 400 comes from another parameter, such as the area geometry added by bbox, or a record count the server refuses. The text then points the user at the wrong input. Consider saying "rejected the query (its where clause or area may be the cause)", or keeping the server's own message as the reason, which the envelope path already carries.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wording; left for the release quality pass.

Comment thread crates/data/src/ogc.rs

/// The pages' features in the first page's collection, without its paging members.
fn finish(mut self, note: Option<String>) -> Step {
let note = if let Phase::Offsets { smaller, .. } = &self.phase

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug (silent drop, medium confidence): this new retry note is added only in finish, but stop (about line 4076) returns early with Step::Done(first, None) when the read holds first (Phase::Offsets { start: None, first: Some(..) }). So if the paged requests from offset 0 fail at every size down to one feature, the caller gets the unpaged first answer with no notice. Both the retry count and the "couldn't be read … layer …, offset …" reason are lost, although the PR says a page that still fails names the layer and offset.

Suggested direction: carry the note through the first fallback, e.g. Some(first) => Step::Done(first, Some(note)), or add the retry count there too. The retry tests also need a case where offset 0 fails while the first answer succeeds. Existing tests that assert Done(first, None) may need updating.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fallback to the first answer when paging fails from offset 0 is what main does today (Done(first, None)), so the features read are the same as before this PR; what's lost is the new retry count. A note there has to tell a complete first answer from a cut-off one, or it would report a loss that didn't happen, so carrying it through is left for the release quality pass rather than done here.

@github-actions

Copy link
Copy Markdown
Contributor

Code review

Bugs

  • Retry notice and failure reason are dropped on the first-page fallback (medium confidence). Pages::stop returns Step::Done(first, None) early when first is still held. That skips finish, so the new "N failed page request(s) retried with smaller pages" note is lost, along with the "couldn't be read … layer …, offset …" reason. If the paged requests from offset 0 fail at every size, the caller gets the unpaged first answer with no notice, which breaks the "never silent" rule. The retry tests don't cover this path. Inline comment posted at crates/data/src/ogc.rs:4126.
  • HTTP 400 is misattributed to the where clause (low confidence). Any 400 on a page with a non-default where reports "rejected … its where clause", even when another parameter (for example the bbox geometry) is the cause. Inline comment posted at crates/data/src/ogc.rs:3839.

Performance

  • The 10-second page limit permanently shrinks page size (medium-low confidence). page_timeout caps every page with size > 1, and the size never grows back. A slow but working server, one page at 12 s, can halve the layer's page size for the rest of the read. That roughly doubles the requests and can turn a read that finished in under a minute into "the pages timed out". This looks deliberate, but it should be confirmed, and the 10-second limit should be documented in docs/user-guide/data-formats.md. Inline comment posted at crates/data/src/ogc.rs:3691.

Security

  • No issues found. The where value is encoded as one query value through with_query_value and encode, so it cannot add or override other parameters. Tokens are redacted in page_failure, and error envelopes are bounded and redacted.

Quality

  • The retry test asserts note.contains("2"), which is nearly always true. It should check the exact count. (low confidence; for the quality pass)
  • The description-timeout error changed from "the layer's description took too long" to "timeout: service page" in crates/ui-egui/src/serviceui.rs:553, and that text now also covers descriptions. The new wording is less clear. (low confidence; for the quality pass)

AGENTS.md

  • The added non-test code has no unwrap, expect or indexing. Retries run on the existing background paths. Timers are not used in tests. The retry notice follows the one-notice-per-kind rule, except for the fallback gap above. Test coverage for the "lossy gives a notice, clean gives none" rule is good apart from that gap.

Prior review threads: none, so no concerns were left out as already raised.

Change size

Compared with main (merge base ce9d740 to PR head c4d544d), the whole PR.

Measure Value
Files changed 5 (added 0, modified 5, removed 0, renamed 0)
Size before 3.44 MB
Size after 3.46 MB
Total size change +19.0 KB
Path Before After Change
crates/data/src/ogc.rs 402.8 KB 416.0 KB +13.1 KB
crates/engine/src/tests.rs 2.83 MB 2.83 MB +3.5 KB
docs/user-guide/data-formats.md 91.2 KB 92.5 KB +1.3 KB
crates/engine/src/cmd/service.rs 94.3 KB 95.2 KB +0.9 KB
crates/ui-egui/src/serviceui.rs 38.2 KB 38.4 KB +223 B

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional comments: 1

crates/data/src/ogc.rs-4126-4127: 1

4126-4127: Minor · Functional Correctness · Quick win

Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Keep the retry notice when paging falls back to the first page.

If the description omits maxRecordCount, read_first can retain an eight-feature first page. If offset requests fail at sizes 8, 4, 2 and 1, three smaller-page retries occur. However, stop returns Step::Done(first, None) without calling finish, so the retry notice is lost.

Carry the retry count through fallback completion and attach the notice to that result.

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: 479218e2-94b1-4082-b0f3-b07888150cd0
Commits

Reviewing files that changed from the base of the PR and between e5fb706 and c4d544d.

Files selected for processing: 5

  • crates/data/src/ogc.rs
  • crates/engine/src/cmd/service.rs
  • crates/engine/src/tests.rs
  • crates/ui-egui/src/serviceui.rs
  • docs/user-guide/data-formats.md

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

@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-2144/
Web app https://preview.rustgis.app/pr-2144/app/
Commit c4d544d

GitHub Pages takes a minute or two to publish a new commit. Newer commits from the fork aren't published until a maintainer adds the preview label (once per commit).

@Mavrick-F
Mavrick-F merged commit 718081e into opengeos:main Nov 15, 2026
21 checks passed
@Mavrick-F Mavrick-F mentioned this pull request Nov 15, 2026
56 of 63 tasks
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.

1 participant