Skip to content

fix(engine): report unreadable route definition queries - #2442

Merged
Mavrick-F merged 1 commit into
opengeos:mainfrom
Mavrick-F:fix/route-query-notice
Nov 19, 2026
Merged

Mavrick-F merged 1 commit into
opengeos:mainfrom
Mavrick-F:fix/route-query-notice

Conversation

@Mavrick-F

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

Copy link
Copy Markdown
Member

Summary

analysis.route silently used every resident line when a saved definition query could no longer be read. Use the shared row resolver with Policy::Query and report that fallback once through a typed, translatable notice. Valid queries still restrict the network; selection remains irrelevant to connectivity. Empty query results remain an empty network.

This changes the shared engine command used by desktop, browser, CLI, Python, touch, Assistant/MCP and plugins. Existing ribbon/search dispatch and route-layer undo remain unchanged; no command options or descriptions change. The resident dataset is borrowed and source row positions, network caching and cancellation are preserved. No external project code was followed.

Testing

  • Command regression route_reports_unreadable_query_and_keeps_query_only_network: two connected source features, one selected, queries keeping both/one/neither, and an unreadable field query. Checks route segment count and one typed fallback notice with literal layer data.
  • Before the fix, that regression failed with zero query notices instead of one; the preceding query/selection/empty-network checks passed. After the fix it passes.
  • Engine unit tests: 1,820 passed, 7 existing ignored; integration suites passed.
  • Engine all-target Clippy with warnings denied; strict wasm engine check; formatting, private preflight and guarded commit hooks passed.
  • Full Linux fork CI passed before publication.

UI evidence

No UI layout or rendering change. The new fallback notice is covered through the actual engine command and its translation payload.

Related issue

Part of #2402 (remaining consumer adoption).

Summary by CodeRabbit

  • Bug Fixes
    • Routing now uses rows that match the layer’s definition query, regardless of which segments are selected.
    • If the definition query can’t be read, routing falls back to the unfiltered rows and reports the issue after a successful route. Invalid segments continue to be reported.

@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The route command now builds its network from rows resolved under Policy::Query, independently of selection. If the definition query is unreadable, it uses unfiltered rows and reports that condition after a successful route. Tests cover query outcomes, route counts, and notice content.

Changes: Route query-based row selection

Layer / File(s) Summary
Route row resolution and reporting
crates/engine/src/cmd/workflows.rs, crates/engine/src/tests.rs
route uses query-resolved rows instead of selection-based visible rows. When the query is unreadable, it uses unfiltered rows and sends a notice after adding the route layer. The documentation and tests describe and verify these behaviors.

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

Change: Bug fix

Possibly related issues

Possibly related PRs

  • opengeos/RustGIS#2247 — Both changes modify the route command’s input row set, which is relevant to the graph reuse behavior described in that PR.

Suggested reviewers: giswqs, elpidioassinaturas

Merge Risk: Minimal · up to 13dac

The change makes analysis.route respect saved definition queries and reports a clear notice when a query cannot be read. The change is narrow and covered by a targeted test, and no merge-blocking risk is apparent.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: route definition queries that cannot be read are now reported. It is specific, uses the engine scope, and matches the summary, objectives, and the added regression tes…
Description check Passed The description covers the summary of the change, the testing performed, and the UI evidence section, which states no visible UI change. The related issue section is filled in with 'Part of #2402'. It…
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 main change: route definition queries that cannot be read are now reported. It is specific, uses the engine scope, and matches the summary, objectives, and the added regression test.

Full details: Description check

Explanation

The description covers the summary of the change, the testing performed, and the UI evidence section, which states no visible UI change. The related issue section is filled in with 'Part of #2402'. It follows the template structure and gives the required reasoning, so it is mostly complete.

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 rows in view,
Then builds a route from query true.
If queries fail, all rows return,
A notice tells what could not parse or learn.
The path is tested, hop by hop,
And onward goes the rabbit’s hop.

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: 48ef73b4-9df7-4764-9525-d595733c3dc8
Commits

Reviewing files that changed from the base of the PR and between fb2a7e5 and 13dac4e.

Files selected for processing: 2

  • crates/engine/src/cmd/workflows.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; 5 remain after this review.

rustgis_map::rows::Rows::All => (0..l.dataset.features.len()).collect(),
rustgis_map::rows::Rows::Subset(rows) => rows,
};
let r = network::shortest_route(

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 (moderate confidence, about 55%): the unreadable-query notice is lost when the route fails. The notice is only emitted after shortest_route(...)? succeeds, so an Err returns before notify_text runs. With a broken definition query the network silently widens to every feature, and if the route then fails, the user sees only "no route" with no hint that their query was ignored. The AGENTS.md "Never silent" rule asks that the fallback be reported. The new test covers only successful routes, so this path is untested.

Suggested fix: emit the notice before returning the error. query_notice is only moved on one path at a time, and l is not used on the Err path, so this should borrow-check, but I have not compiled it.

Suggested change
let r = network::shortest_route(
let r = match network::shortest_route(
&l.dataset,
&rows,
point(p, "from")?,
point(p, "to")?,
cost,
f(p, "snapDistance").unwrap_or(1000.0).clamp(0.0, 1e6),
) {
Ok(r) => r,
Err(error) => {
if let Some(notice) = query_notice {
s.notify_text(notice, false);
}
return Err(error);
}
};

A regression case would be a broken query on a network where the endpoints can't connect: assert the error and one query notice.

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 notice describes a successful route made without its unreadable query. When shortest_route fails, no output dataset or route layer is added. This follows the same successful-result notice policy as Simulation. Also, Session::guarded withdraws ordinary non-error notices on failure (lib.rs, the (Err(_), Some(snap)) branch), so moving notify_text(..., false) onto the error path would not retain it. The route failure remains the reported outcome.

@github-actions

Copy link
Copy Markdown
Contributor

Code review

Bugs

  • crates/engine/src/cmd/workflows.rs:1695 (moderate confidence, about 55%): the unreadable-query notice is emitted only after shortest_route succeeds. If the route fails, the notice is dropped and the user sees only "no route", with no sign that their broken query was ignored. Posted inline with a suggested fix. The new test covers only successful routes, so this path is untested.

Security

  • None found.

Performance

  • None found. Rows are now resolved lazily through resolve_rows. The Rows::All path still allocates the full index list, as the old visible_rows() path did.

Quality

  • Nit, not posted: the template hard-codes "1 layer" and "that query". This is accurate for a single-layer command but bakes the count into the translatable string, unlike gp.rs, which passes a count.

AGENTS.md

  • Compliant on the points I checked: no unwrap in non-test code, the typed NoticeText path is used, both clean and lossy inputs are tested, and Effects::NONE with no roles means no new capability or ribbon change.

Verified correct

  • The row logic matches the old behaviour. resolve_rows(Policy::Query, None) uses the same query compile and matches as visible_rows(), so only the reporting is new.
  • NoticeText::english() substitutes arguments in a single pass, so the test's layer name Roads {error} is handled correctly.
  • Borrows look sound: l is last used before add_dataset(s, …).

Prior reviews: none existed on this PR, so no concerns were skipped as already raised.

Outside this diff (not raised): neighborhood at workflows.rs:1736 still calls visible_rows() and falls back silently on a broken query. That is pre-existing and probably belongs to the remaining consumer adoption (#2402).

Change size

Compared with main (merge base fde9aea to PR head 13dac4e), the whole PR.

Measure Value
Files changed 2 (0 added, 2 modified, 0 removed, 0 renamed)
Size before 3.21 MB
Size after 3.21 MB
Total size change +3.1 KB
Path Before After Change
crates/engine/src/tests.rs 3.11 MB 3.11 MB +2.5 KB
crates/engine/src/cmd/workflows.rs 107.4 KB 108.0 KB +645 B

@Mavrick-F

Copy link
Copy Markdown
Member Author

The failed-route notice point is answered inline: no route is committed, and the session guard withdraws ordinary informational notices on failure. Successful fallback routes report the parser error once.

The fixed-count wording is accurate for this single-input command; a wording/template refactor is left for the release quality pass. Neighborhood is already recorded as the next separate consumer slice.

@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-2442/
Web app https://preview.rustgis.app/pr-2442/app/
Commit 13dac4e

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 added this pull request to the merge queue Nov 19, 2026
Merged via the queue into opengeos:main with commit 41d8b5d Nov 19, 2026
24 checks passed
@Mavrick-F
Mavrick-F deleted the fix/route-query-notice branch November 19, 2026 07:59
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