Skip to content

fix(engine): read an inline file's base64 data when checking capabilities - #3227

Merged
jgregoriorincon merged 2 commits into
opengeos:mainfrom
jgregoriorincon:fix/3221-template-data-capabilities
Nov 28, 2026
Merged

jgregoriorincon merged 2 commits into
opengeos:mainfrom
jgregoriorincon:fix/3221-template-data-capabilities

Conversation

@jgregoriorincon

@jgregoriorincon jgregoriorincon commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

report.existingTemplate and presentation.import read base64 data before text, but their capability checks read only text. A saved step passing a layout as data listed none of layout-text-statistics, layout-legend-fit, layout-legend-class-labels or layout-sections, and a presentation passed as data did not list layout-text-statistics, so a RustGIS without them could replay it and lose those settings.

The checks now read the inline file with inline_text, the same data-before-text choice the commands make. It now lends text instead of copying it, as every save asks each check about it. A data the command refuses asks for nothing.

Not in this PR:

Testing

New rows in the legend-fit, text-statistics and presentation map-page capability tests, run as a task step and through script.run: data with and without the setting, invalid base64, and data winning over text. The three tests failed before their change and pass with it. fmt, clippy, nextest, doctests, the layer check and the schema check pass; after the last commit, fmt, clippy for rustgis-engine and its capability, report, presentation and hostile-params tests (191 pass).

UI evidence

No visible UI change.

Related issue

Closes #3221

Summary by CodeRabbit

  • Bug Fixes
    • Presentation and layout imports now correctly recognize supported capabilities when inline content is provided as base64 data, rather than plain text.
    • Capability checks now follow the same content-selection behavior when both base64 data and text are supplied, improving consistency in how import content is interpreted.

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change updates inline text handling to borrow text input and use owned content for decoded data. Layout and presentation capability checks now inspect inline content through the shared helper, with tests for base64 data inputs.

Changes: Inline content capability inspection

Layer / File(s) Summary
Inline text ownership
crates/engine/src/cmd/items.rs
inline_text borrows text input and returns owned decoded base64 or package content. read_text converts the result to an owned string.
Capability checks and coverage
crates/engine/src/project_capabilities.rs
Layout and presentation capability checks use inline_text. Tests cover base64 data, invalid data, and cases where both data and text are present.

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

Change: Bug fix · Severity of issue fixed: Medium

Possibly related issues

  • Issue 3226: The PR updates layout capability checks for inline content, but the issue describes additional layout capabilities beyond those covered by this change.

Suggested reviewers: mavrick-f

Merge Risk: Minimal · up to 14360

This change makes report and presentation capability checks inspect base64 data input the same way as text input. No concrete merge-blocking risk was found, and the reported tests cover the new cases.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: capability checks now read base64 data for inline files, as the fix. It is specific and matches the changeset in project_capabilities.rs and items.rs. It uses a conven…
Linked Issues check Passed Directly linked issue #3221 requires that a saved report.existingTemplate step passing a layout as base64 data list the same capabilities as the same layout passed as text. The reviewed head routes re…
Out of Scope Changes check Passed The changed files are crates/engine/src/cmd/items.rs (inline_text now returns Cow; read_text converts to an owned String), crates/engine/src/project_capabilities.rs (layout and presentation.impor…
Description check Passed The description follows the repository template. It has Summary, Testing, UI evidence and Related issue sections. The Summary explains the change and why it is needed: the capability checks for report…
Full details: Title check

Explanation

The title names the main change: capability checks now read base64 data for inline files, as the fix. It is specific and matches the changeset in project_capabilities.rs and items.rs. It uses a conventional commit prefix, which is clear for history scanning.

Full details: Linked Issues check

Explanation

Directly linked issue #3221 requires that a saved report.existingTemplate step passing a layout as base64 data list the same capabilities as the same layout passed as text. The reviewed head routes report.existingTemplate and layout.import through the shared imported_layout_uses check (crates/engine/src/project_capabilities.rs, command_uses_text_statistics and related arms). The PR states that the layout and presentation.import checks now read inline content through crate::cmd::items::inline_text, which follows the data-before-text order that read_text uses. Per the PR description and the summary, the new tests cover layout-legend-fit, layout-text-statistics and presentation map-page cases with data, with invalid base64, and with data taking precedence over text. The PR description and the new tests cover the four named layout capabilities (layout-text-statistics, layout-legend-fit, layout-legend-class-labels, layout-sections). The PR limits its scope to those four because the other layout capability checks apply only to layout.import. Under that reading, a text-supplied layout also gives report.existingTemplate none of the other capabilities, so data and text reach parity. Limit of evidence: the diff read was truncated before the layout_capabilities body and the presentation.import arm, so the exact capability list was checked against the PR description and summary, not fully against source lines.

Full details: Out of Scope Changes check

Explanation

The changed files are crates/engine/src/cmd/items.rs (inline_text now returns Cow<str>; read_text converts to an owned String), crates/engine/src/project_capabilities.rs (layout and presentation.import checks read inline_text; new base64 test cases), and the capability, report, presentation and hostile-params tests named in the PR. Each change supports the #3221 fix: the Cow change avoids a copy in the shared helper, and the tests cover the new data path. No unrelated feature, refactor or documentation change appears in the summary. The PR description also names two non-changes (other layout capabilities for report.existingTemplate, and layout.import with both data and text), which the PR leaves untouched. Limit of evidence: the source diff was truncated, so the test-file contents were not read 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 change and why it is needed: the capability checks for report.existingTemplate and presentation.import read only text, while the commands read base64 data before text. The Testing section lists the new test rows, the three tests that failed before and pass after, and the checks that were run. The UI evidence section states no visible UI change, which the template allows. The Related issue section names Closes #3221. Scope limits are stated explicitly. The description is specific and complete, 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 the layout’s text,
Then finds its encoded data next.
The borrowed words go hopping by,
The decoded ones are owned nearby.
Capabilities now see both ways,
And tests keep watch through changing days.

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: b56dd501-9cd2-43fb-8ae1-5749ec03e3b4
Commits

Reviewing files that changed from the base of the PR and between 30fcf3c and 143603e.

Files selected for processing: 2

  • crates/engine/src/cmd/items.rs
  • crates/engine/src/project_capabilities.rs

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

@github-actions

Copy link
Copy Markdown
Contributor

Code review

Bugs

  • layout.import is checked against the wrong payload (crates/engine/src/project_capabilities.rs:806, inline comment posted). imported_layout now goes through inline_text, which reads data first. layout.import reads only text or path, and its text has no size cap. So for {"data": A, "text": B} the capability check reads A while the command imports B, and a step whose text uses a feature can be saved without that capability. An oversize text also loses its check. Confidence: medium-high on the code, medium on how often it happens (it needs malformed input). Fix: keep layout.import on its own text-only read.

Security

  • None found. The new base64 path keeps the existing max_file()/3*4 pre-decode bound, and the decode error is swallowed into "requires nothing", which matches the command refusing the input.

Performance

  • Each save decodes a step's data once per capability check. About 25 layout checks run for layout.import/report.existingTemplate, and each one allocates a full decoded copy of up to max_file(). The copies are transient, one at a time, but the work is O(checks × size). Decoding once per save would avoid it. Confidence: medium. Low severity.

Quality

  • The imported_layout doc comment says data is read "as report.existingTemplate reads them", which is inaccurate for its layout.import caller (covered in the bug above).
  • Tests cover data for report.existingTemplate and presentation.import only. Add layout.import cases with data-only, data plus text, and oversize text.

AGENTS.md

  • No rule break found. There are no new commands, parameters or saved-file changes, so command-surface.txt and the schema need no update. The change is headless, with no ribbon, UI or wasm-only code, and no new threads or unwrap/expect. The new tests use fixed expected values.

Twins checked

  • report.existingTemplate: the read in open_inputs (cmd/report.rs:1464) and the three capability branches (lines 425, 444, 474) all go through the changed helper, so they agree.
  • presentation.import: read_text (cmd/items.rs:459) and the capability check both use inline_text with data before text. The only capability branch is line 296.
  • layout.import: not consistent with the change (see bug above).
  • No #[cfg(target_arch = "wasm32")] branches changed.

Earlier concerns left alone: 0. The PR has no prior review threads.

Change size

Compared with the base branch (merge base 5cdcf5b to PR head 143603e).

Files changed Added Modified Removed Renamed Size before Size after Total change
2 0 2 0 0 301.3 KB 303.2 KB +1.9 KB
Path Size before Size after Change
crates/engine/src/project_capabilities.rs 196.4 KB 198.1 KB +1.7 KB
crates/engine/src/cmd/items.rs 104.9 KB 105.0 KB +144 B

@jgregoriorincon

Copy link
Copy Markdown
Contributor Author

On the review summary:

  • layout.import given both data and text: right, the check now follows data while the command imports text. layout.import declares no data and says it ignores it, so this takes a malformed step. The description lists it under "Not in this PR".
  • An oversize text: layout.import refuses a layout over 64 MiB, and the reader's limit is never under 512 MiB, so no layout that imports loses its check.
  • Decoding data once per check: only a step that carries data pays it, and only on a save.
  • The doc comment and the layout.import test rows follow from the first point, so they stay as they are.

@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-3227/
Web app https://preview.rustgis.app/pr-3227/app/
Commit 143603e

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
jgregoriorincon added this pull request to the merge queue Nov 28, 2026
Merged via the queue into opengeos:main with commit 65e1068 Nov 28, 2026
28 checks passed
@jgregoriorincon
jgregoriorincon deleted the fix/3221-template-data-capabilities branch November 28, 2026 14:31
elpidioassinaturas pushed a commit to elpidioassinaturas/RustGIS that referenced this pull request Nov 28, 2026
Brings in opengeos#3227, opengeos#3228 and opengeos#3209, merged meanwhile. No conflicts.

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]: report.existingTemplate given a layout as data asks for no layout capability

1 participant