Skip to content

fix(project): check a saved layout import step against the layout its command reads - #3552

Closed
jgregoriorincon wants to merge 3 commits into
opengeos:mainfrom
jgregoriorincon:fix/3482-layout-import-requirements
Closed

jgregoriorincon wants to merge 3 commits into
opengeos:mainfrom
jgregoriorincon:fix/3482-layout-import-requirements

Conversation

@jgregoriorincon

@jgregoriorincon jgregoriorincon commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A saved step (task, model, script or history) that brings in a layout had its project requirements worked out from data when it carried one, and from text otherwise. report.existingTemplate reads them in that order, but layout.import reads text and never data. A step with a layout in text that uses a newer option and a plain layout in data saved a project that didn't require that capability, so an older release wouldn't refuse it, although the layout the step imports uses an option that release drops.

The requirements now come from the layout each command reads (imported_layout in project_capabilities.rs):

  • layout.import: text only.
  • report.existingTemplate: nothing when layout names a layout of the project (the same cause: any text or data beside it was checked although the command ignores it); otherwise data, then text, as before.

No command, parameter or file format changes. Desktop, browser, command line and Python share this engine code.

Testing

  • New test a_saved_import_step_is_checked_against_the_layout_its_command_reads (tests/layout_files.rs): both commands, a script line, an inline model step, and a task run showing the imported layout is the one checked. It fails on main and passes here.
  • cargo nextest run -p rustgis-engine -E 'test(layout_) | test(capabilit) | test(an_inline_graph_node)': 542 passed.
  • A task with that mixed step, saved with rustgis-cli: no requires on main, ["layout-element-wrap"] here.
  • cargo fmt --all and cargo clippy -p rustgis-engine --all-targets -- -D warnings: clean.

UI evidence

No visible UI change.

Related issue

Closes #3482

Summary by CodeRabbit

  • Bug Fixes
    • Improved layout capability detection for imported layouts and saved steps. Import commands now check their layout text, while existing-template commands check inline content when no layout is specified. This helps ensure projects correctly identify when wrapped-layout support is required and preserves the expected layout when a saved import step runs.

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Layout capability checks now select inline content based on the command ID. Tests cover saved-step requirements for layout.import and report.existingTemplate, and verify importing wrapped layout text.

Changes: Layout capability checks

Layer / File(s) Summary
Command-specific layout input selection
crates/engine/src/project_capabilities.rs
Capability checks pass the command ID to the imported-layout helper. layout.import checks text; report.existingTemplate checks inline content only when layout is absent. Other command IDs yield no imported layout.
Saved-step requirement tests
crates/engine/src/tests/layout_files.rs
Tests check requirements against the payload selected for each command, cover script and inline model steps, and verify that a saved layout.import step imports wrapped text.

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

Change: Bug fix · Severity of issue fixed: Medium

Possibly related issues

Possibly related PRs

  • opengeos/RustGIS#3548 — This PR overlaps in the command-specific input selection for layout.import and report.existingTemplate.

Suggested reviewers: elpidioassinaturas, m-hollis-1

Merge Risk: Minimal · up to f98f8

Saved layout-import steps now record the project requirements for the layout their command actually reads. This closes the case where an older release could silently drop a newer layout option on import. No remaining merge-blocking risk was found, and the new test covers the changed behavior.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the fix and the area it touches: a saved layout import step is now checked against the layout its command reads. The changeset matches this. It changes imported-layout capability check…
Description check Passed The description follows the template. Summary explains the cause and the fix for layout.import and report.existingTemplate. Testing lists the new test, the nextest run, a CLI comparison, and fmt and c…
Linked Issues check Passed Issue #3482 requires that a saved layout.import step derive its project requirements from the layout the command imports, not from data. The PR summary states that layout.import now checks text only, …
Out of Scope Changes check Passed The change to report.existingTemplate is in the same imported_layout helper and fixes the same class of defect: requirements taken from a payload the command does not read. The PR summary and the test…
Full details: Title check

Explanation

The title names the fix and the area it touches: a saved layout import step is now checked against the layout its command reads. The changeset matches this. It changes imported-layout capability checks in project_capabilities.rs for layout.import and report.existingTemplate, and adds a test covering that behavior. The title is specific and does not need to list every detail.

Full details: Description check

Explanation

The description follows the template. Summary explains the cause and the fix for layout.import and report.existingTemplate. Testing lists the new test, the nextest run, a CLI comparison, and fmt and clippy results. UI evidence states that there is no visible UI change, as the template allows. Related issue links #3482 with 'Closes'. The template's comment-only placeholders are removed, which is expected.

Full details: Linked Issues check

Explanation

Issue #3482 requires that a saved layout.import step derive its project requirements from the layout the command imports, not from data. The PR summary states that layout.import now checks text only, through imported_layout in crates/engine/src/project_capabilities.rs, which takes the command ID. The new test a_saved_import_step_is_checked_against_the_layout_its_command_reads covers layout.import in a script line, an inline model step and a task run, and the author reports that it fails on main and passes here. Limit: the diff and the imported_layout body could not be read (diff unavailable, file truncated), so this verdict relies on the PR summary and the reported test result. The issue text mentions path as well as text. The PR summary does not say how a path-based import is handled, and no saved payload is evident for it, so this is not treated as a gap.

Full details: Out of Scope Changes check

Explanation

The change to report.existingTemplate is in the same imported_layout helper and fixes the same class of defect: requirements taken from a payload the command does not read. The PR summary and the test cover report.existingTemplate. No command, parameter or file format changes. The changes to crates/engine/src/project_capabilities.rs and crates/engine/src/tests/layout_files.rs connect to #3482. The diffs themselves could not be read, so this rests on the PR summary.

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 layout text,
And finds the features tucked inside.
It hops through saved steps, neat and clear,
While named layouts take their proper turn.
The wrapped words arrive intact,
And carrots celebrate the check.

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: 4c9b3099-ff81-437f-ad89-48cddb269f60
Commits

Reviewing files that changed from the base of the PR and between e11b061 and f98f8ce.

Files selected for processing: 2

  • crates/engine/src/project_capabilities.rs
  • crates/engine/src/tests/layout_files.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

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Code review

Verdict: I found no bugs, security issues or AGENTS.md breaks in this change. I did not run the tests (no shell here), so the new test's pass is unverified. I read the code paths it depends on.

Bugs: None found.

  • layout.import reads text, then path, and never data. The new branch (project_capabilities.rs, imported_layout) matches that order. Confidence: high.
  • report.existingTemplate reads layout first when it is a string, then data, then text, then path (via items::read_text → inline_text). The new branch returns nothing when layout is a string and otherwise uses inline_text, matching it. Confidence: high.
  • A layout read from path is not checked here. This looks intentional: the doc comment at project_capabilities.rs:1351 says a file's own header records what it needs. Confidence: high that it is by design.

Security: None found. The new code uses ps and Value::get, not indexing, and adds no unsafe or unwrap calls in non-test code.

Performance: None found. Cow::Borrowed avoids copies, and the parse still runs only when a key matches or may be escaped, as before.

Quality (not posted as inline comments; minor):

  • layout.import now skips the max_file cap that inline_text applied, so an oversized text is parsed for the check. The command refuses it at run time anyway, and project size bounds it in practice. Confidence: medium that it matters; low impact.
  • The test does not cover report.existingTemplate with a non-string layout (which should behave as absent). Confidence: high that the gap exists, low that it matters.

Test claims checked by reading:

  • a_saved_import_step_is_checked_against_the_layout_its_command_reads uses helpers that exist (with_layout, base64 as a normal engine dependency).
  • The model step key tool matches ModelStep.
  • The script-line form layout.import {json} is assumed to parse as the test expects; I did not verify the script parser.
  • The test should fail on main: data is read before text there, so the mixed case reports no wrap requirement. This follows from the code, not from a run.

Twins checked:

  • Every layout.import / report.existingTemplate capability check now passes id through imported_layout_uses or imported_layout. No caller still uses the old signature.
  • project.openText reads text only, and the diff does not change it.
  • Inline model steps and script.run route through the same capability function.
  • No #[cfg(target_arch = "wasm32")] branch changes, so the wasm twin does not apply.

AGENTS.md: No break found.

  • The PR changes no command, parameter or saved file format, so command-surface.txt and the project schema need no update.
  • The test uses assert!, not assert_eq! on identical sides.
  • The PR body states which surfaces the change reaches.

Prior concerns: There were no earlier review threads, so none were left alone.

No inline comments were posted because I found no finding worth one.

Change size

Compared with the base branch: the whole PR against main (merge base 5799813 to PR head f98f8ce).

Measure Value
Files changed 2 (0 added, 2 modified, 0 removed, 0 renamed)
Size before 306.9 KB (314,247 B)
Size after 309.8 KB (317,224 B)
Total size change +2.9 KB (+2,977 B)
Path Before After Change
crates/engine/src/tests/layout_files.rs 15.1 KB 17.4 KB +2.4 KB
crates/engine/src/project_capabilities.rs 291.8 KB 292.4 KB +565 B

@jgregoriorincon

Copy link
Copy Markdown
Contributor Author

On the two minor points of the review, no change in this PR:

  • layout.import no longer applying max_file(): without that cap, the check can only parse a longer text, never skip one it read before. A text over MAX_LAYOUT (64 MiB) is refused by import when the step runs, and max_file() is never below 512 MiB, so at worst a step that fails anyway asks for a capability.
  • A non-string layout for report.existingTemplate: the command and the check read it with the same ps(params, "layout"), so both treat it as absent.

@jgregoriorincon

Copy link
Copy Markdown
Contributor Author

Closing: #3548 fixes the same bug (#3496) in the same function and covers every case here, plus the layout size limit. #3482 reports the same bug, so #3548 will close it too.

@jgregoriorincon
jgregoriorincon deleted the fix/3482-layout-import-requirements branch December 1, 2026 17:04
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]: A saved layout.import step is checked against its data, while it imports its text

1 participant