Skip to content

fix(cog): preserve GDAL metadata loss notices - #1844

Merged
giswqs merged 1 commit into
opengeos:mainfrom
choupeanut:codex/1812-cog-metadata-losses
Nov 12, 2026
Merged

giswqs merged 1 commit into
opengeos:mainfrom
choupeanut:codex/1812-cog-metadata-losses

Conversation

@choupeanut

@choupeanut choupeanut commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

An in-place COG applied its GDAL metadata and then replaced the resulting loss messages with the header losses. Metadata that referenced absent bands or contained unsupported class items was therefore silently omitted from the session notices.

Initialize the header losses before applying metadata, preserving both sets for the existing landing-notice pipeline. No new dependencies or serialized fields.

Testing

  • Regression exercises actual COG range reads through layer.addUrl, covering clean metadata, simultaneous header/metadata losses, and a wavelength assigned to an absent band.
  • Checks the raster retains each loss and the session reports each once; repeated landing polls add no notices.
  • RUST_TEST_THREADS=4 cargo xtask ci passed on the original base 12829268 (format, Clippy with warnings denied, workspace tests, layering).
  • Initial runs with the default test parallelism hit the unrelated WMS popup test; it passed alone and the full 884-test UI suite passed with four threads. One retry also hit the known STAC connection flake ([Bug]: stac_search_by_shape_says_what_it_leaves_out fails intermittently in CI with a connection error #1840, fix proposed in test(engine): the routes test server reads a request whole before answering #1842); the final complete CI run passed without skipping any tests.
  • pre-commit run --all-files and cargo build --locked --target wasm32-unknown-unknown -p rustgis-web passed on the original base.
  • Updated the branch onto main cf61cc65 to resolve concurrent additions at the end of the engine test file, retaining all upstream tests and placing this regression beside the existing COG tests. The production fix is unchanged. Full local checks are being repeated; GitHub CI is running on the updated head.

UI evidence

No visible UI change. This restores loss reporting through the existing notification mechanism; no controls or map rendering change.

Related issue

Closes #1812. Related to the remaining work in #1331.

Summary by CodeRabbit

  • Bug Fixes
    • In-place COG processing now reports metadata losses more accurately, including cases involving nonexistent bands.
    • Repeated raster-notice checks no longer add duplicate metadata-loss notices.
    • Metadata that is retained during processing is no longer incorrectly reported as lost.

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The COG overview raster now assigns layout losses before applying GDAL metadata. A test checks loss reporting for clean metadata, lossy metadata, and metadata naming a nonexistent band, including repeated landing-notice calls.

Changes: COG metadata loss reporting

Layer / File(s) Summary
Preserve and report metadata losses
crates/tiles/src/cog/raster.rs, crates/engine/src/tests.rs
read_overview assigns layout losses before applying GDAL metadata. The test checks expected losses for clean, lossy, and nonexistent-band cases, and verifies that repeated landing-notice calls add no notices.

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

Change: Bug fix · Severity of issue fixed: Low

Possibly related issues

  • opengeos/RustGIS#1331 — The issue concerns reporting omitted COG content when background reads land; this change tests COG metadata loss notices during raster landing.

Possibly related PRs

  • opengeos/RustGIS#1339 — Introduces the in-place COG path and loss-notice pipeline exercised by this change.

Suggested reviewers: giswqs, siiinc

Merge Risk: Minimal · up to e5876

In-place COG reads now keep both header and GDAL metadata loss notices. The change is small and tested, and no actionable merge risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title 'fix(cog): preserve GDAL metadata loss notices' names the main change: in-place COG reads kept header losses and replaced metadata losses, and the fix now preserves both in the landing notic…
Linked Issues check Passed Issue #1812 requires that an in-place COG keep the header losses and the losses that apply_pam records from GDAL_METADATA, so that notice_landed_rasters reports both once. The whole-PR diff against th…
Out of Scope Changes check Passed The whole-PR diff against the merge base contains one moved line and one added line in crates/tiles/src/cog/raster.rs. The change only reorders the lost assignment relative to apply_pam, which impleme…
Description check Passed The description follows the repository template. It has Summary, Testing, UI evidence, and Related issue sections. The Summary explains the bug, which is that header losses replaced metadata losses, a…
Full details: Title check

Explanation

The title 'fix(cog): preserve GDAL metadata loss notices' names the main change: in-place COG reads kept header losses and replaced metadata losses, and the fix now preserves both in the landing notices. It is specific and concise, and it matches the raw summary's change to read_overview and the new regression test.

Full details: Linked Issues check

Explanation

Issue #1812 requires that an in-place COG keep the header losses and the losses that apply_pam records from GDAL_METADATA, so that notice_landed_rasters reports both once. The whole-PR diff against the merge base changes crates/tiles/src/cog/raster.rs in read_overview. The line r.lost = i.layout.lost.clone() now runs before r.apply_pam(described, GDAL_METADATA). The former assignment after apply_pam, which overwrote the metadata losses, is removed. This matches the fix the issue proposes. The issue states that apply_pam appends to r.lost. I could not read apply_pam in crates/data/src/raster/mod.rs within the output limit, so the append behaviour rests on the issue text and on the reported symptom. The regression test in crates/engine/src/tests.rs could not be read: the blob is missing from the checkout. Its coverage rests on the PR description and the change summary. These describe clean metadata, simultaneous header and metadata losses, a wavelength on an absent band, single reporting, and no repeat notices on repeated landing polls. Header losses, absent-band and no-data losses, and differing no-data losses are therefore covered by the code path and the described test.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff against the merge base contains one moved line and one added line in crates/tiles/src/cog/raster.rs. The change only reorders the lost assignment relative to apply_pam, which implements #1812. The change summary reports a regression test of +31 lines in crates/engine/src/tests.rs for the same objective, and reports no public declaration changes. The PR description reports no UI, control, or dependency changes. No unrelated change was found in the readable evidence. The test file content could not be read, so its scope is assessed from the summary only.

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, which is that header losses replaced metadata losses, and the fix, which initializes header losses before applying metadata. The Testing section lists the regression test, the CI and pre-commit runs, and the flaky test retries. The UI evidence section states no visible UI change, which the template allows. The Related issue section cites #1812 and #1331. The description is thorough. One minor gap is that the Testing section mentions a wasm32 build that was still being repeated, so the final verification state is not fully settled.

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 raster’s trail,
Where metadata losses used to fail.
The notices now name what’s gone,
And repeat calls add none anon.
Clean bands leave the message clear,
The bunny hops away from here.

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: eec835f3-3cf3-447f-aab7-ef0aa1543a5b
Commits

Reviewing files that changed from the base of the PR and between fbf1ee4 and e587681.

Files selected for processing: 1

  • crates/engine/src/tests.rs

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

@github-actions

Copy link
Copy Markdown
Contributor

Code review

I found no bugs, security issues, performance problems, or AGENTS.md violations in this PR, so there are no inline comments. I checked the changed lines against their surroundings, but I did not compile or run the tests here. The PR reports a passing cargo xtask ci.

What I verified

  • Bugs: The fix is correct. Raster::apply_pam (crates/data/src/raster/mod.rs:783) extends self.lost rather than replacing it. The old order (apply the metadata, then assign r.lost = i.layout.lost.clone()) discarded every metadata loss. Moving the assignment above apply_pam keeps both sets. read_overview is the only place a COG raster is built from layout.lost, so no other path has the same overwrite.
  • Test: The regression test covers the three cases it claims: clean, header and metadata losses together, and a wavelength on an absent band. Every helper and field it uses exists with the expected shape (example_with, Example::{classes, lossy, wavelengths}, serve_ranges, notice_landed_rasters, notice_mark, notices_since). The expected message strings match the source. Its unwrap() calls are in test code, which the existing file already does.
  • Wasm and layering: The change is inside crates/tiles, touches no platform-specific code, and adds no dependencies.
  • Prior reviews: prior-reviews.json has no threads, so no earlier concerns were raised or left alone.

Minor, not worth an inline comment

  • The test asserts exact data.lost.len() values. A future extra loss message in the fixture would break it, though that is what the test is meant to catch.

Change size

Compared with main (merge base 1282926 to PR head fbf1ee4).

Measure Value
Files changed 2 (0 added, 2 modified, 0 removed, 0 renamed)
Size before 2.48 MB (2,604,281 B)
Size after 2.49 MB (2,606,001 B)
Total size change +1.7 KB (+1,720 B)
File Before After Change
crates/engine/src/tests.rs 2.45 MB 2.46 MB +1.7 KB
crates/tiles/src/cog/raster.rs 31.0 KB 31.0 KB 0 B

@choupeanut
choupeanut force-pushed the codex/1812-cog-metadata-losses branch from fbf1ee4 to e587681 Compare November 12, 2026 13:33
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I found no bugs, security issues, or performance problems. The change is a two-line reorder plus a regression test, and the reorder fixes the bug it targets. Prior review threads: none exist on this PR, so no earlier concerns were skipped.

Bugs: None. read_overview (crates/tiles/src/cog/raster.rs:127-129) assigned r.lost = i.layout.lost.clone() after apply_pam, which discarded every metadata loss apply_pam had just added. The PR moves the assignment before apply_pam. I checked that apply_pam uses self.lost.extend(...) and pushes (crates/data/src/raster/mod.rs:784-834), and that nothing else in the function clears or overwrites lost. The fix is correct. The sibling path crates/engine/src/cmd/layer.rs:4762-4765 already uses the right order, so this was the only outlier.

Security: None.

Performance: None.

Quality:

  • crates/engine/src/tests.rs:28 asserts data.lost.len() == expected.len(), an exact count. The other assertions use any(), which is looser. I could not run the tests here, so I have not confirmed that the lossy and out-of-range fixtures produce exactly two and one losses. If a fixture yields an extra loss from a later change, this test will fail for a reason unrelated to the message it checks. Confidence: low. This is a nit and can wait for the release quality pass.

AGENTS.md: Compliant. The fix keeps the existing notice_landed_rasters path, so losses are reported through Session::notify and not eprintln!. Clean and lossy inputs are both tested. The new code is test-only and adds no unwrap to non-test code. No new dependencies.

I did not run the test suite or the wasm build, because this review only had read access to the repository. The PR description reports a passing cargo xtask ci.

Change size

Compared: the whole PR against main (merge base cf61cc6 to PR head e587681).

Measure Value
Files changed 2 (0 added, 2 modified, 0 removed, 0 renamed)
Size before 2.50 MB (2,617,886 B)
Size after 2.50 MB (2,619,606 B)
Total size change +1.7 KB (+1,720 B)
Path Before After Change
crates/engine/src/tests.rs 2.47 MB 2.47 MB +1.7 KB
crates/tiles/src/cog/raster.rs 31.0 KB 31.0 KB 0 B

@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-1844/
Web app https://preview.rustgis.app/pr-1844/app/
Commit e587681

GitHub Pages takes a minute or two to publish a new commit.

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.

A COG read in place never says what its GDAL metadata loses: lost is overwritten after apply_pam

2 participants