Skip to content

fix(engine): refuse unread parameters on layout.addElement grid and extentIndicator (#2890) - #3060

Merged
jgregoriorincon merged 1 commit into
opengeos:mainfrom
ninhhaidang:fix/2890-layout-grid-indicator-keys
Nov 27, 2026
Merged

jgregoriorincon merged 1 commit into
opengeos:mainfrom
ninhhaidang:fix/2890-layout-grid-indicator-keys

Conversation

@ninhhaidang

@ninhhaidang ninhhaidang commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Add per-kind parameter allow-lists (ADD_EXTENT_INDICATOR_KEYS and ADD_GRID_KEYS) and only_add_keys validation in crates/engine/src/cmd/layout.rs for layout.addElement "extentIndicator" and "grid".
  • Any non-null key not read by that kind is refused before mutating the layout or pushing an undo step, naming the rejected key and listing the keys that kind reads (layout.addElement: a grid takes no "..." (it reads ...) / layout.addElement: an extent indicator takes no "..." (it reads ...)).
  • Explicit null values for unread keys continue to be accepted as not given, while earlier kind-specific checks (ONLY_FILL, ONLY_OUTLINE, NO_OVERLAY_BACKGROUND, ONLY_DASH, ONLY_SCALE_BAR_DETAILS, etc.) keep their existing behavior and messages.

Surfaces reached

  • Desktop, browser, CLI, Python, mobile (ui-touch), Assistant/MCP, plugins: all invoke layout.addElement through rustgis-engine. No ribbon/shortcut/dialog surface is added or changed.

Testing

  • cargo test -p rustgis-engine --lib cmd::layout::tests — passed (including 3 new regression tests: add_element_grid_refuses_unread_parameters_without_mutating, add_element_extent_indicator_refuses_unread_parameters_without_mutating, add_element_grid_and_extent_indicator_allow_null_unread_keys_and_all_valid_keys_silently)
  • cargo test -p rustgis-engine --lib tests::hostile_params_never_panic — passed (8 test shards)
  • cargo test -p rustgis-engine --lib command_surface_matches_the_snapshot — passed
  • cargo test -p rustgis-engine --tests — passed (all unit + integration tests)
  • cargo clippy -p rustgis-engine --all-targets -- -D warnings — passed
  • cargo xtask test-hygiene, cargo xtask layers, cargo xtask rows — passed
  • RUSTFLAGS='-D warnings' cargo check --locked --target wasm32-unknown-unknown -p rustgis-web — passed
  • cargo fmt --check — passed

UI evidence

No visible UI change.

Related issue

Fixes #2890
Follow-up: #3074 tracks extending per-kind unread-parameter allow-lists to the remaining layout.addElement kinds.

Summary by CodeRabbit

  • Bug Fixes
    • Grid and extent-indicator elements now report unrecognized options and list the accepted ones.
    • Explicit null values are accepted for options these elements do not use. Invalid options no longer change the layout or undo state.

Copilot AI balanced review requested due to automatic review settings November 27, 2026 01:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Grid and extent-indicator creation now rejects unread non-null parameters and reports the first unrecognized key with the accepted keys. Null values remain allowed. Tests verify that rejection does not change the layout or undo depth.

Changes: Element parameter validation

Layer / File(s) Summary
Per-kind parameter validation
crates/engine/src/cmd/layout.rs
Grid and extent-indicator creation now checks supplied keys against per-kind accepted-key lists. The validator ignores null values and rejects the first unrecognized non-null key.
Validation behavior tests
crates/engine/src/cmd/layout.rs
Tests cover rejection without layout or undo-state changes, null values, valid options, and existing kind-specific errors.

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

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

  • opengeos/RustGIS#1459: It changes the same layout.addElement refusal behavior for kind-specific parameters.
  • opengeos/RustGIS#2271: It adds background options and rejection rules for grids and extent indicators in the same command.
  • opengeos/RustGIS#1846: It adds an MGRS option that shares the grid parameter contract.

Suggested reviewers: giswqs, jgregoriorincon

Merge Risk: Minimal · up to dae5c

The change makes grid and extent-indicator creation reject unread non-null parameters before the layout changes, with a clear error. Valid calls still work, and no concrete merge risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: layout.addElement now refuses unread parameters for grid and extentIndicator kinds. It also cites the issue number. It is specific and matches the changeset and linked…
Linked Issues check Passed Issue #2890 asks that layout.addElement refuse non-null parameters that a grid or extentIndicator does not read, before any change, with a message naming the key and listing the keys the kind reads. T…
Out of Scope Changes check Passed Per the summary, all changes sit in crates/engine/src/cmd/layout.rs: per-kind key lists, the validation for the two kinds, and the three regression tests. These implement issue #2890 directly. The PR …
Description check Passed The description follows the repository template. It has a Summary that states the change, the per-kind allow-lists, and the error format. It has a Testing section that lists the commands run and the t…
Full details: Title check

Explanation

The title names the main change: layout.addElement now refuses unread parameters for grid and extentIndicator kinds. It also cites the issue number. It is specific and matches the changeset and linked objectives.

Full details: Linked Issues check

Explanation

Issue #2890 asks that layout.addElement refuse non-null parameters that a grid or extentIndicator does not read, before any change, with a message naming the key and listing the keys the kind reads. The PR summary and raw summary describe per-kind allow-lists (ADD_GRID_KEYS, ADD_EXTENT_INDICATOR_KEYS) in crates/engine/src/cmd/layout.rs, checked before mutation or undo push. The message format matches the issue's example. Explicit null values for unread keys are accepted, as the issue requires. Existing kind-specific checks (ONLY_FILL, ONLY_OUTLINE, etc.) are kept. Three regression tests cover refusal without mutation, null handling, and valid keys. The issue's scope is limited to grid and extentIndicator, and the PR respects that. Limitation: the file diff could not be read (changed blobs unavailable, and the file read was truncated), so the code-level behavior rests on the PR summary and the reported test results, not on a direct read of the validation code.

Full details: Out of Scope Changes check

Explanation

Per the summary, all changes sit in crates/engine/src/cmd/layout.rs: per-kind key lists, the validation for the two kinds, and the three regression tests. These implement issue #2890 directly. The PR states no UI, ribbon, or dialog change. The PR does not extend the check to rectangle or text kinds, which the issue lists as follow-up work. No unrelated change is identified. Limitation: the full diff could not be read, so the absence of other edits rests on the PR summary and the raw summary (+258/-0, one file).

Full details: Description check

Explanation

The description follows the repository template. It has a Summary that states the change, the per-kind allow-lists, and the error format. It has a Testing section that lists the commands run and the three new regression tests. It has a UI evidence section that correctly says 'No visible UI change.' It has a Related issue section that links Fixes #2890 and a follow-up #3074. All required sections are filled in with specific information, so the check passes.

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 each grid key twice,
And guards the frame from stray advice.
Null may pass without a sound,
Unknown keys are turned around.
The layout stays as it began,
While carrots wait beside the plan.

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: 5e6ea055-2b7d-4831-8d0a-605fec3c8c7b
Commits

Reviewing files that changed from the base of the PR and between 09f7541 and dae5ce6.

Files selected for processing: 1

  • crates/engine/src/cmd/layout.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.

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

Copy link
Copy Markdown
Contributor

Code review

Scope: crates/engine/src/cmd/layout.rs only. The PR adds only_add_keys with per-kind allow-lists for layout.addElement grid and extentIndicator. Both checks run before any mutation, and explicit nulls are still accepted.

Bugs

  • Twin kinds still drop unread keys (pre-existing, medium-high confidence). northArrow, and likely other kinds, accept keys they never read. {"kind": "northArrow", "bold": true} is silently dropped, because bold is read only for text. align, letterSpacing and italic look the same. This is the same silent loss the PR fixes, so it should be extended or tracked as a follow-up. Posted inline on layout.rs:7570.

Security

  • None found.

Performance

  • None found. The check is a linear scan over a handful of keys.

Quality

  • Refusal messages use the layout.addElement: prefix, but the neighbouring errors in this file (of must be another map frame, no layout) don't. Pick one convention.
  • only_add_keys reports only the first unread key, so a caller with several bad keys fixes them one per call. Listing them all would be friendlier.
  • The tests rely on serde_json's default BTreeMap key order for the "first key" assertions. That holds, since preserve_order isn't enabled, but the comment should say it is an assumption.

AGENTS.md

  • No violations found. Test-only unwrap is covered by the clippy test allowance, and the change adds no wasm, UI or command-surface change. command-surface.txt is untouched because no parameter keys were added or removed.

Checked and fine

  • Ribbon callers (ribbon.rs:3500, 3514): send only kind, off, of, frame and layout, all on the allow-lists.
  • Grid keys: the allow-list matches the keys grid_params and the grid arm read (type, crs, short, labelSize, mgrs, labels, edges, off, etc.).
  • extentIndicator keys: the allow-list matches of, frame, color, width and layout.
  • Existing kind-specific checks (ONLY_FILL, NO_OVERLAY_BACKGROUND, ONLY_DASH, ONLY_SCALE_BAR_DETAILS) still run before the new check, so their messages are unchanged.
  • Tests: they cover refusal without mutation or undo, silent acceptance of nulls and valid keys, and the existing messages.
  • Prior reviews: none exist on this PR, so nothing was left out as already raised.

Change size

Compared with the base branch (merge base b985666 to PR head dae5ce6).

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

@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

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

@jgregoriorincon
jgregoriorincon added this pull request to the merge queue Nov 27, 2026
Merged via the queue into opengeos:main with commit 9bdf3a9 Nov 27, 2026
28 checks passed
elpidioassinaturas pushed a commit to elpidioassinaturas/RustGIS that referenced this pull request Nov 27, 2026
Since main's opengeos#3060 they refuse any key they don't read; the help says so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MikeFTV pushed a commit to MikeFTV/RustGIS that referenced this pull request Nov 27, 2026
…engeos#2872)

* feat(layout): section lines on a map frame (opengeos#2863 part 1)

A map frame keeps section lines, as it keeps its grid: each across the
whole frame, straight on the page, through a place it follows when the
frame is panned, turned or rescaled, with its name at both ends (A and
A'), a colour, a width and a dash, clipped to the frame's shape.
Commands, undo and the Format pane change them; one whose place the
frame doesn't show isn't drawn, which they and exports say.

A frame without one keeps its bytes; one with any requires
layout-section, in projects, layout files and saved commands.

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

* fix(layout): a section line on a frame whose map is missing is said; its name boxes keep its transparency

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

* refactor(layout): section lines' Format pane rows move to a part of their own (opengeos#2863)

The layout view's notice of the section lines it doesn't draw stays.

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

* fix(layout): layout.addElement refuses what a section doesn't read

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

* fix(layout): a removed section line takes no change; a line missing for two reasons counts once

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

* fix(layout): spaces round a section name are not counted as cut

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

* test(capabilities): a sample for layout-section

The check main brought wants one sample per command capability.

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

* fix(layout): a report says the section lines its layout page can't draw

- report.export says the section lines a report's layout page leaves out,
  once a layout, as the layout's own export does.
- report.existingTemplate requires layout-section when its layout file has
  section lines, as layout.import does.
- A section's name box stays inside its frame across the line too, and the
  frame's credit keeps clear of every name, not only the right and bottom ones.
- Clearer wording for Section::free_name.

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

* test(layout): each section test under its own doc comment

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

* test(layout): a grid or an extent indicator refuses a section's name

Since main's opengeos#3060 they refuse any key they don't read; the help says so.

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

* fix(layout): section names on short lines, the credit beside them, and Mercator's reach

- A vertical line's names are both right labels to the credit, which goes
  left of them rather than above them out of the frame.
- On a line too short for both names at their size, they are drawn smaller
  (down to 0.4 of it), each clear of the other.
- A place a flat projection holds to its reach (Web Mercator past 85.05°)
  isn't drawn at the latitude it is held to; the notice says it.
- The grid and extent indicator arms no longer call say_name_ignored, which
  their key checks made unreachable.
- Each render section test under its own doc comment.

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

* fix(layout): one report notice for the section lines its layouts leave out

- A report with several layouts that each leave a section line out says
  it once, counting them all, each line named with its layout (AGENTS.md:
  one notice per kind with a count).
- layout.addElement's help says a section adds no element: the reply's
  "element" is its frame and "section" its name.

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

---------

Co-authored-by: elpidioassinaturas <elpidiofilho@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
jgregoriorincon pushed a commit to jgregoriorincon/RustGIS that referenced this pull request Nov 28, 2026
opengeos#2863 part 1b) (opengeos#3140)

* feat(layout): section lines on a map frame (opengeos#2863 part 1)

A map frame keeps section lines, as it keeps its grid: each across the
whole frame, straight on the page, through a place it follows when the
frame is panned, turned or rescaled, with its name at both ends (A and
A'), a colour, a width and a dash, clipped to the frame's shape.
Commands, undo and the Format pane change them; one whose place the
frame doesn't show isn't drawn, which they and exports say.

A frame without one keeps its bytes; one with any requires
layout-section, in projects, layout files and saved commands.

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

* fix(layout): a section line on a frame whose map is missing is said; its name boxes keep its transparency

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

* refactor(layout): section lines' Format pane rows move to a part of their own (opengeos#2863)

The layout view's notice of the section lines it doesn't draw stays.

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

* feat(layout): section lines in the Format pane (opengeos#2863 part 1b)

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

* feat(layout): section lines dragged in the layout view (opengeos#2863 part 1b)

A section line of the selected map frame can be dragged across itself. Its place keeps where it is along the line; off the frame, its ground or its projection, the line stays where it was.

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

* fix(layout): layout.addElement refuses what a section doesn't read

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

* fix(layout): a removed section line takes no change; a line missing for two reasons counts once

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

* fix(layout): spaces round a section name are not counted as cut

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

* test(capabilities): a sample for layout-section

The check main brought wants one sample per command capability.

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

* fix(layout): a report says the section lines its layout page can't draw

- report.export says the section lines a report's layout page leaves out,
  once a layout, as the layout's own export does.
- report.existingTemplate requires layout-section when its layout file has
  section lines, as layout.import does.
- A section's name box stays inside its frame across the line too, and the
  frame's credit keeps clear of every name, not only the right and bottom ones.
- Clearer wording for Section::free_name.

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

* test(layout): each section test under its own doc comment

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

* test(layout): a grid or an extent indicator refuses a section's name

Since main's opengeos#3060 they refuse any key they don't read; the help says so.

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

* fix(layout): section names on short lines, the credit beside them, and Mercator's reach

- A vertical line's names are both right labels to the credit, which goes
  left of them rather than above them out of the frame.
- On a line too short for both names at their size, they are drawn smaller
  (down to 0.4 of it), each clear of the other.
- A place a flat projection holds to its reach (Web Mercator past 85.05°)
  isn't drawn at the latitude it is held to; the notice says it.
- The grid and extent indicator arms no longer call say_name_ignored, which
  their key checks made unreachable.
- Each render section test under its own doc comment.

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

* fix(layout): one report notice for the section lines its layouts leave out

- A report with several layouts that each leave a section line out says
  it once, counting them all, each line named with its layout (AGENTS.md:
  one notice per kind with a count).
- layout.addElement's help says a section adds no element: the reply's
  "element" is its frame and "section" its name.

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

* fix(layout): a section line's drag lets go when a command changes the frame's lines

A drag keeps the line it took as well as its index: one removed, moved or
replaced meanwhile (a command, an undo, a script) is let go, and the drop
moves no other line in its place.

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

* fix(layout): a section line's drag keeps its name, and a drop off the frame stays

A drag takes the line's name as well as its place: a line put at the same
place under another name meanwhile is let go, not moved in its stead. And a
drop with the pointer off the frame (beside it, at a height inside it) lands
nowhere, as the cursor then says.

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

* fix(layout): a section line dropped outside a round or polygon frame's shape stays

A drop counts as on the frame only within the frame's shape (a circle, an
ellipse or a polygon, turned with the frame), not anywhere in its box. Tests
also cover a rename to a name another line has: refused, and said.

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

---------

Co-authored-by: elpidioassinaturas <elpidiofilho@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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]: layout.addElement of a grid or an extent indicator drops the parameters it doesn't read, without a word

3 participants