Skip to content

fix(layout): refuse a colorbar, legend or frame shape value of the wrong type - #3181

Merged
jgregoriorincon merged 1 commit into
opengeos:mainfrom
jgregoriorincon:fix/3169-typed-colorbar-values
Nov 28, 2026
Merged

jgregoriorincon merged 1 commit into
opengeos:mainfrom
jgregoriorincon:fix/3169-typed-colorbar-values

Conversation

@jgregoriorincon

@jgregoriorincon jgregoriorincon commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A colorbar or legend option, or a frame's shape, given with a value of the wrong type was ignored: the command succeeded and kept the value the element already had, or its default (a shape of 17 made a rectangle). It is now refused, naming the key and what it takes, with nothing changed.

  • It covers a colorbar's tickSide, ticks, layer and title and a legend's title in layout.addElement and layout.update, and the shape of layout.addFrame.
  • The keys are read with the existing given_name and given_num ([Bug]: Layout commands ignore a grid or scale bar value of the wrong type without a word #3110), so the messages for an unknown name stay as they were.
  • layout.update now reads ticks before it changes anything, so a refusal leaves no half-made change.
  • On layout.update, title is checked only for a legend or a colorbar; a chart still says what its own title takes.
  • null means not given, and a number written as text ("7") is still read.
  • A caller that sent a wrong type before, an empty string for ticks included, now gets an error. The ribbon and the Format pane already send the right types.
  • Every surface runs these commands, so the refusal reaches the desktop, the browser, the phone layout, the CLI, Python, the Assistant, MCP and tasks. Command search and the tool descriptions are unchanged (no new command or key), and a refusal leaves no Undo step.

Not in this PR: the layer, field and rows of a table or chart (#3180).

Testing

  • New tests in crates/engine/src/tests/layout_typed_values.rs; the two that expect the new refusals failed before the fix.
  • Full checks (fmt, clippy, nextest, doctests, layers, cargo xtask schema --check) passed on the commit.

UI evidence

No visible UI change.

Related issue

Closes #3169

Summary by CodeRabbit

  • Bug Fixes
    • Layout settings for legends, colorbars, frames, and chart titles now validate supplied values. Invalid types or unsupported options are reported instead of being silently ignored.
    • Invalid updates are rejected without changing the existing layout.
    • Colorbar tick values are checked, rounded, and constrained to supported limits. Missing or null tick values remain unspecified.
    • Valid frame shapes, legend and colorbar titles, and colorbar options continue to be accepted.

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Layout commands now validate selected colorbar, legend, and frame-shape values. Invalid supplied values return errors instead of being silently ignored. Colorbar tick values are validated before update mutation.

Changes: Layout value validation

Layer / File(s) Summary
Validate values when adding layout elements
crates/engine/src/cmd/layout/elements.rs, crates/engine/src/cmd/layout/frame.rs, crates/engine/src/tests/layout_typed_values.rs
Legend titles, colorbar layer and title values, tick sides, tick counts, and frame shapes use validated readers. Tests cover invalid and valid frame shapes.
Validate updates before mutation
crates/engine/src/cmd/layout/update.rs, crates/engine/src/tests/layout_typed_values.rs
Updates validate legend and colorbar titles, layers, and ticks before mutation. Tests cover wrong-type values, null handling, valid values, and preservation of state when an update is refused.

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

Change: Bug fix · Severity of issue fixed: Low

Possibly related issues

  • #3110 — It covers the same wrong-type value handling for grid, scale bar, and north arrow options, using shared validation behavior.
  • #3180 — It covers similar wrong-type values for tables and charts, but this PR does not implement those changes.

Possibly related PRs

  • opengeos/RustGIS#3161 — It implements related strict type reads for other layout options and shares validation behavior with this PR.

Suggested reviewers: m-hollis-1, elpidioassinaturas

Merge Risk: Minimal · up to 99d3c

Layout commands now reject wrongly typed colorbar, legend and frame-shape values with clear errors and leave existing elements unchanged. No merge-blocking risk is evident. Callers that previously sent a wrong type, such as an empty string for ticks, will now get an error.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: layout commands now refuse a colorbar, legend, or frame shape value of the wrong type. It matches the summary, the objectives, and the linked issue #3169, and it uses …
Linked Issues check Passed Issue #3169 asks that layout commands refuse wrong-typed values for colorbar tickSide, ticks, layer and title, legend title, and addFrame shape, naming the key and accepted type, with no change on ref…
Out of Scope Changes check Passed All changed areas map to the listed keys in #3169: elements.rs (colorbar and legend parsing in addElement, ticks parser signature), frame.rs (addFrame shape), update.rs (update validation order and ti…
Description check Passed The description follows the template's Summary, Testing, UI evidence, and Related issue sections. It explains the behavior change (wrong-typed colorbar, legend, and frame-shape values are now refused …
Full details: Title check

Explanation

The title names the main change: layout commands now refuse a colorbar, legend, or frame shape value of the wrong type. It matches the summary, the objectives, and the linked issue #3169, and it uses the conventional fix(layout) prefix. The title is specific and concise.

Full details: Linked Issues check

Explanation

Issue #3169 asks that layout commands refuse wrong-typed values for colorbar tickSide, ticks, layer and title, legend title, and addFrame shape, naming the key and accepted type, with no change on refusal. Evidence at the reviewed head: update.rs reads a legend or colorbar title with given_name(p, "title", "text") before any mutation. For colorbars, layer is read with given_name, and orientation, tick_side and ticks are parsed in one step before the element is changed. The ticks parser now returns Result<Option<usize>, String>, so a supplied invalid value (including an empty string) is an error. The summary states that addElement uses given_name for legend and colorbar titles, colorbar layer and tickSide, and that add_frame reads shape with given_name, keeping "rectangle" as the default. The two new tests that expect refusals are reported to fail before the fix. Null still means not given, and numeric text is still read. Table and chart layer, field and rows are excluded by the PR and the issue does not require them. The add-path behavior is taken from the PR summary and the AI-generated change summary; elements.rs and frame.rs diffs could not be read directly, so this rests on the source read of update.rs plus those summaries.

Full details: Out of Scope Changes check

Explanation

All changed areas map to the listed keys in #3169: elements.rs (colorbar and legend parsing in addElement, ticks parser signature), frame.rs (addFrame shape), update.rs (update validation order and title/layer/ticks checks), and layout_typed_values.rs (tests for these refusals, null handling, valid inputs, and a chart title check). The chart title check in update.rs only refuses non-text titles for charts and does not change chart behavior otherwise. Table and chart layer, field and rows handling is not changed, consistent with the PR's stated exclusion. No unrelated change was found in the evidence read. The elements.rs and frame.rs diffs were not directly readable, so this conclusion relies on the summary for those files.

Full details: Description check

Explanation

The description follows the template's Summary, Testing, UI evidence, and Related issue sections. It explains the behavior change (wrong-typed colorbar, legend, and frame-shape values are now refused with no changes), the scope (tickSide, ticks, layer, title, and addFrame shape), and the null and numeric-text handling. The Testing section names the new test file and the checks run. The UI evidence section states no visible UI change, as the template allows. The Related issue section cites #3169, and the linked issue objectives match the described scope.

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 title’s type,
And counts the ticks with care.
A frame rejects a shape gone wrong,
A null may still be there.
Updates wait till checks are done,
Then hop along their way.

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: 2ed45b7d-6daa-42aa-b214-7c96d96e8ce5
Commits

Reviewing files that changed from the base of the PR and between 40a1bff and 99d3c55.

Files selected for processing: 4

  • crates/engine/src/cmd/layout/elements.rs
  • crates/engine/src/cmd/layout/frame.rs
  • crates/engine/src/cmd/layout/update.rs
  • crates/engine/src/tests/layout_typed_values.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.

@github-actions

Copy link
Copy Markdown
Contributor

Code review

I found no bugs, security issues or performance problems in this PR. I did not run the tests (no shell here), so the claims about test results rest on reading the code.

What I checked

  • Refusals happen before any mutation. layout.update now reads ticks, title and the other keys before its first change, and the tests assert the project and Undo label are unchanged.
  • null still means "not given" through given_name and given_num, and numeric strings such as "7" still parse through f().
  • Twins: the frame shape has no layout.update twin (ps(p, "shape") appears only in effects, graphics and layer). The chart title is still refused by chart_update. ticks() has only two callers, both updated. The ribbon and Format pane send correct types (colorbar.rs sends numeric ticks and a string tickSide; legend.rs sends a boolean allClasses).
  • Booleans (reverse, allClasses, hideOther, showNoData) still read through b(), which emits an unread-value notice (Unrecognised boolean parameter text is read as false without a notice #1600), so they are not silent drops.
  • No saved fields and no new command parameters changed, so cargo xtask schema and the command-surface.txt snapshot don't need updating.

Bugs: none found.

Security: none found.

Performance: none found.

Quality

  • crates/engine/src/cmd/layout/inputs.rs:105 and :215-216 still read the colorbar layer with ps(), which treats a wrong type as absent. This is harmless today because the command refuses the value afterwards, but the input collector and the command now disagree about what a wrong-type layer means. Confidence: high that it's harmless, medium that it's worth aligning. Category: quality.

AGENTS.md

  • The PR body doesn't say which surfaces the change reaches, as the "Reach every surface" rule asks. It should state the desktop, browser, CLI, Python, phone, ribbon and command search, the Assistant and MCP tool descriptions (layout.rs:211 already names ticks and tickSide), and the undo path (a refusal leaves no Undo step). Confidence: high. Category: agents-md.

Prior concerns: there were no existing review threads on this PR, so none were left alone.

Not verified: the PR body's claim that fmt, clippy, nextest and the layers check passed on the commit, and the claim that the two tests expecting new refusals failed before the fix.

Change size

Compared: the whole PR against main (merge base 032e917 to PR head 99d3c55).

Measure Value
Files changed 4 (added 0, modified 4, removed 0, renamed 0)
Size before 119.2 KB (122,073 B)
Size after 123.2 KB (126,143 B)
Total size change +4.0 KB (+4,070 B)
Path Before After Change
crates/engine/src/tests/layout_typed_values.rs 5.4 KB 8.9 KB +3.5 KB
crates/engine/src/cmd/layout/update.rs 40.2 KB 40.5 KB +290 B
crates/engine/src/cmd/layout/elements.rs 52.8 KB 52.9 KB +146 B
crates/engine/src/cmd/layout/frame.rs 20.8 KB 20.9 KB +57 B

@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-3181/
Web app https://preview.rustgis.app/pr-3181/app/
Commit 99d3c55

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).

@jgregoriorincon

Copy link
Copy Markdown
Contributor Author

On the two points: the surfaces are now listed in the description. inputs.rs is left as it is: the input walk only gathers what the command is about to read, and the command refuses a wrong-typed layer right after, so nothing is changed because of it.

@jgregoriorincon
jgregoriorincon added this pull request to the merge queue Nov 28, 2026
Merged via the queue into opengeos:main with commit d9ae54e Nov 28, 2026
28 checks passed
@jgregoriorincon
jgregoriorincon deleted the fix/3169-typed-colorbar-values branch November 28, 2026 02:36
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 commands ignore a colorbar, legend or frame shape value of the wrong type without a word

1 participant