Skip to content

fix(engine): require what the layout an import step reads uses (#3496) - #3548

Merged
jgregoriorincon merged 2 commits into
opengeos:mainfrom
jgregoriorincon:fix/3496-layout-import-reads
Dec 1, 2026
Merged

jgregoriorincon merged 2 commits into
opengeos:mainfrom
jgregoriorincon:fix/3496-layout-import-reads

Conversation

@jgregoriorincon

@jgregoriorincon jgregoriorincon commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A saved layout.import step that gave both data and text wasn't checked against the layout it imports: the capability checks read data first, while the command reads text (or path) and never data. The saved project then didn't require what the layout in text uses, so an older version could accept it and drop those settings when the step runs. The same happened with a data that isn't base64.

All the checks read an imported layout through one function, imported_layout (crates/engine/src/project_capabilities.rs), which now takes the command's id and reads what that command reads:

  • layout.import: text only.
  • report.existingTemplate: nothing when layout names a layout (the command reads no file then), else data before text, as before.
  • Either: nothing over the 64 MiB a layout file may take, which both commands refuse.

So some steps now require less than before: a layout.import whose data holds a feature its text doesn't, a report.existingTemplate that names a layout and also carries a file, and either with an oversized layout. In each case the command never imports what was being checked.

The change is in the engine's check on save, so it reaches the desktop app, the browser, the command line, Python and the Assistant alike. No command, parameter or UI text changes; docs/maintaining.md now says what each of the two commands reads.

Testing

  • New test a_saved_import_step_requires_what_its_command_reads (crates/engine/src/tests/layout_import_reads.rs), eleven cases, each as a task step and a model step, one through a script.run line. Before the fix, six of its first nine cases failed; the two oversize cases were added later and failed on the first version of the fix. All pass now.
  • The two projects from the issue, opened and saved with rustgis-cli run --project p.rgis --save out.rgis: on main (5799813b) the data + text one saves no requires; with this change both save ["layout-legend-column-breaks"].
  • On the first commit: fmt, clippy, doctests, layers, schema --check and test-hygiene pass; nextest ran 11,929 tests, 11,921 passed. The 8 failures are in rustgis-geolibre (7) and the ui-egui smoke test line_strokes_editor_edits_one_class, code this change doesn't touch, and they fail locally on other branches too.
  • On the final commit: the capability and column-break tests (102), engine clippy, fmt and test-hygiene pass.

UI evidence

No visible UI change.

Related issue

Closes #3496
Closes #3482

Summary by CodeRabbit

  • Bug Fixes

    • Capability checks now account for the layout content an import step actually reads, helping identify when saved tasks and models require support for legend column breaks.
    • Checks skip missing, irrelevant, or oversized layout content and respect named layouts when provided.
  • Documentation

    • Clarified which layout inputs are considered for capability detection, including how named layouts affect input handling.

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Capability detection now reads inline layouts according to the importing command. It skips oversized inputs. Tests cover the input rules across task and model steps, and maintenance documentation describes them.

Changes: Layout capability detection

Layer / File(s) Summary
Command-aware input detection
crates/engine/src/cmd/layout.rs, crates/engine/src/project_capabilities.rs
Layout feature checks now select input by command. layout.import checks text; report.existingTemplate skips inline input when layout names a layout and otherwise prefers data over text. Inputs larger than MAX_LAYOUT are skipped.
Input behavior validation
crates/engine/src/tests.rs, crates/engine/src/tests/layout_import_reads.rs, docs/maintaining.md
Tests check layout capability detection for task and model steps, including wrapped imports and oversized inputs. Documentation describes the input-selection rules.

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

Change: Bug fix · Severity of issue fixed: Medium

Possibly related issues

  • #3226 — The PR passes the command ID through layout feature checks, including checks used for report.existingTemplate.
  • #3221 — The PR checks report.existingTemplate layout content and prefers data over text when no named layout is supplied.
  • #3482 — The PR makes layout.import capability checks read text rather than data.

Possibly related PRs

  • opengeos/RustGIS#3227 — Both PRs change input selection for save-time capability checks involving report.existingTemplate.

Suggested reviewers: elpidioassinaturas, m-hollis-1

Merge Risk: Minimal · up to bea10

Saved layout import steps now record the capabilities of the layout they actually read. No merge-blocking risk remains. The docs-preview CI failure comes from a failed download of its build tool, not from this change.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(engine): require what the layout an import step reads uses (#3496)" matches the main change: save-time capability checks for layout.import and report.existingTemplate now inspect the la…
Linked Issues check Passed [#3496] The issue requires a saved layout.import step to require the capabilities of the layout its command imports. The command reads text only, and the checks read data first. The change routes …
Out of Scope Changes check Passed The engine change in project_capabilities.rs is the shared capability reader that the issue names. It is scoped to the commands the reader serves: layout.import, report.existingTemplate, and script.ru…
Description check Passed The description follows the repository template: it has Summary, Testing, UI evidence, and Related issue sections. The Summary explains the bug (layout.import checks data before text, which it never r…
Full details: Title check

Explanation

The title "fix(engine): require what the layout an import step reads uses (#3496)" matches the main change: save-time capability checks for layout.import and report.existingTemplate now inspect the layout input each command actually reads. It is a short, single-sentence conventional-commit style title, but the wording is slightly awkward and the phrase "what the layout an import step reads uses" is dense. It is still specific enough for a teammate scanning history to understand the primary change.

Full details: Linked Issues check

Explanation

[#3496] The issue requires a saved layout.import step to require the capabilities of the layout its command imports. The command reads text only, and the checks read data first. The change routes the shared imported_layout reader (crates/engine/src/project_capabilities.rs) through the command id, so layout.import reads text only. The new test crates/engine/src/tests/layout_import_reads.rs checks this for task steps and model steps. Its rows cover: text only with column_breaks (requires layout-legend-column-breaks); data plus text where data is plain or not base64 (requires it, because text is read); and data holding the broken layout with plain text (does not require it). The issue's acceptance criterion, that the text layout's column_breaks capability appears in requires, is covered by the first two rows. The changes to report.existingTemplate and the 64 MiB limit extend the same per-command reads and are not needed for #3496 alone. I did not read the body of imported_layout because the file read was truncated. The verdict rests on the test assertions, the summary, and the PR's reported run results. I did not run the tests.

Full details: Out of Scope Changes check

Explanation

The engine change in project_capabilities.rs is the shared capability reader that the issue names. It is scoped to the commands the reader serves: layout.import, report.existingTemplate, and script.run lines that wrap them. The report.existingTemplate and 64 MiB rules follow from the same requirement, that each check read what its command reads. MAX_LAYOUT becoming pub(crate) in cmd/layout.rs supports the shared size check. The test module registration in tests.rs and the docs/maintaining.md update support the change. No command, parameter, or UI text changes. I found no unrelated change in the reviewed evidence. The file read was truncated, so I could not inspect every hunk of project_capabilities.rs directly.

Full details: Description check

Explanation

The description follows the repository template: it has Summary, Testing, UI evidence, and Related issue sections. The Summary explains the bug (layout.import checks data before text, which it never reads), the fix (imported_layout now takes the command id and reads what that command reads), and the affected cases. Testing lists a new eleven-case test, CLI reproduction on the issue projects, and the full nextest results with the failures explained. UI evidence states 'No visible UI change,' which the template allows. Related issue lists Closes #3496 and #3482. The description is complete and specific.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
Fix failing CI checks

  • 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 layout text,
Then skips the data it won't inspect.
Named layouts take a different way,
Big inputs wait outside today.
The column breaks are counted right,
And documented in plain sight.

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: b49c4af2-12f2-419b-9f39-980500a77a91
Commits

Reviewing files that changed from the base of the PR and between ab8a812 and bea10c7.

Files selected for processing: 5

  • crates/engine/src/cmd/layout.rs
  • crates/engine/src/project_capabilities.rs
  • crates/engine/src/tests.rs
  • crates/engine/src/tests/layout_import_reads.rs
  • docs/maintaining.md

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

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Code review

I found no bugs, security issues or performance problems. The change makes each save-time check read the layout the same way its command does: layout.import reads text only, report.existingTemplate reads nothing when layout names a layout and otherwise reads data before text, and both refuse a layout over MAX_LAYOUT. I checked this against cmd/layout.rs, cmd/layout/files.rs, cmd/report.rs and cmd/items.rs::read_text.

Bugs: none found.

Security: none found. The new code adds no panics, and t.len() as u64 is safe.

Performance: none new. layout.import no longer decodes data for its checks, and the Cow borrow avoids copies. The per-check decode of report.existingTemplate data predates this PR.

Quality:

  • crates/engine/src/project_capabilities.rs:1375: the comment says a path "names a file this doesn't open". layout.import does open it (cmd/layout.rs:474). The check still ignores it, as before this PR, and the file's own header covers it ([Feature]: Layout files (.rgislayout): a checked format header, so an older RustGIS refuses what it can't keep #2277). Inline comment posted, confidence high. The PR description's "text only" wording has the same problem.
  • docs/maintaining.md:469-470 also says layout.import reads text, never data, without mentioning path. Same fix, confidence high.

AGENTS.md: no breaks found.

  • Schema: the capability names are unchanged and schema/project.schema.json lists them, so the schema needs no update.
  • Twins checked: presentation.import and layer.addLayerFile use read_text, and style.*, map.import and project.openText use inline_text, so their checks match their commands' data-before-text precedence. layout.import and report.existingTemplate are the only layout readers, and both are covered.
  • Test layout_import_reads.rs covers both ways (lossy and clean) and runs as task and model steps.

Prior review threads: none existed, so none were left alone.

Change size

Compared with the base branch (main, merge base 5799813 to PR head bea10c7), covering the whole PR.

Measure Value
Files changed 5 (1 added, 4 modified, 0 removed, 0 renamed)
Size before 4.23 MB
Size after 4.23 MB
Total size change +4.0 KB
Path Before After Change
crates/engine/src/tests/layout_import_reads.rs 0 B 3.0 KB +3.0 KB
crates/engine/src/project_capabilities.rs 291.8 KB 292.6 KB +824 B
docs/maintaining.md 38.4 KB 38.6 KB +183 B
crates/engine/src/tests.rs 3.84 MB 3.84 MB +67 B
crates/engine/src/cmd/layout.rs 64.5 KB 64.5 KB +11 B

@jgregoriorincon
jgregoriorincon added this pull request to the merge queue Dec 1, 2026
Merged via the queue into opengeos:main with commit 4214bfd Dec 1, 2026
27 of 28 checks passed
@jgregoriorincon
jgregoriorincon deleted the fix/3496-layout-import-reads branch December 1, 2026 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant