Skip to content

A refused Lightroom photo with id 0 no longer skips every master - #4072

Open
THEtheChad wants to merge 1 commit into
storytold:mainfrom
THEtheChad:fix/lr-refused-id-zero
Open

THEtheChad wants to merge 1 commit into
storytold:mainfrom
THEtheChad:fix/lr-refused-id-zero

Conversation

@THEtheChad

@THEtheChad THEtheChad commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #4071

Problem

In a Lightroom catalog whose refused image (for example, an original on another computer) has id_local 0, which takes a malformed or crafted catalog, apply_prepared (crates/engine/src/lightroom_catalog.rs) skips every master. Originals on disk import as bare records without rating, flag, edits, keywords or collections; offline ones get no record; a virtual copy fails the import with virtual copy N: missing master. Nothing warns about the skipped photos.

The check skipped a photo whose masterImage is a refused id, and masterImage is 0 for every master.

Change

  • The refused-master check applies only to virtual copies (master != 0), as refuse_non_media in the same file already does, with a comment saying why.

Tests

In crates/engine/src/lightroom_catalog/tests.rs:

  • a_refused_photo_with_id_zero_refuses_only_itself and a_refused_photo_with_id_zero_leaves_other_virtual_copies_their_master fail with only the guard reverted (nothing imported; virtual copy 2: missing master) and pass with it.
  • a_virtual_copy_of_a_refused_original_is_refused_with_it covers the other side of the guard; it fails with the clause removed entirely.
  • cargo xtask ci on this branch (base e9c29e2): all 9 steps passed. cargo test -p lightcraft-engine --lib: 1659 passed.
  • Merged locally with main 27b755a: cargo test -p lightcraft-engine --lib -- lightroom_catalog (59) passes.
  • The real lightcraft-cli importing a crafted catalog: with the fix, ratings, pick and the virtual copy come through; with the guard reverted they don't. The desktop app was not run.

Notes

`masterImage` is 0 for every master, so when a catalog image whose
original is refused has `id_local` 0 (a malformed or crafted catalog),
the refused-master check in `apply_prepared` matched every master and
skipped it. Originals on disk were still added by the file import, but
without their Lightroom rating, flag, edits, keywords or collection
membership; offline masters got no record; a virtual copy of a skipped
master failed the import with "virtual copy N: missing master", leaving
the bare file records behind. The reader warns about the refused photo,
but nothing warned about the photos that were skipped.

The check now skips 0, as `refuse_non_media` already does. Tests cover
the id-0 case with and without a virtual copy, and a virtual copy of a
refused original with a path of its own, which is still refused.
@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Lightroom catalog import now checks a refused master ID only when it is nonzero. Tests cover imports with a refused photo whose ID is zero and with a virtual copy of a refused master.

Changes: Refused Lightroom photo handling

Layer / File(s) Summary
Guard refused master ID zero
crates/engine/src/lightroom_catalog.rs, crates/engine/src/lightroom_catalog/tests.rs
The import no longer treats a refused master ID of zero as a match for every master. Tests check that a sample master and optional virtual copy import when a refused photo has ID zero, and that a virtual copy of a refused master is not imported, even when it has a local path and appears first.

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

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: aiongg

Merge Risk: Minimal · up to 63106

The guard addresses the reported refused-ID-zero import case, and the supplied review identifies no remaining merge-blocking issue.

Pre-merge checks: Passed 4

Check name Status Explanation
Linked Issues check Passed Issue #4071 requires checking a refused master only when master != 0. The change applies that guard in apply_prepared. The three added tests cover a refused image with ID 0, importing its unrelate…
Out of Scope Changes check Passed The reported changes are limited to the refused-master guard and focused regression tests for issue #4071. The tests directly support the issue objective. No unrelated changes are identified.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title states the main fix: a refused Lightroom photo with ID 0 no longer causes every master to be skipped. The raw summary says the refused-master check in apply_prepared now applies only when th…
Full details: Linked Issues check

Explanation

Issue #4071 requires checking a refused master only when master != 0. The change applies that guard in apply_prepared. The three added tests cover a refused image with ID 0, importing its unrelated master and virtual copy, and refusing a virtual copy whose master was refused. The reported CI and engine test results support the implementation.

Full details: Title check

Explanation

The title states the main fix: a refused Lightroom photo with ID 0 no longer causes every master to be skipped. The raw summary says the refused-master check in apply_prepared now applies only when the master ID is nonzero, and the added tests cover refused ID-0 photos. The title is specific and matches the changeset, so it 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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between e60a725 and 63106db.

Files selected for processing: 2

  • crates/engine/src/lightroom_catalog.rs
  • crates/engine/src/lightroom_catalog/tests.rs

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

1234destiny1234 referenced this pull request in 1234destiny1234/lightcraft-classic Nov 15, 2026
…itself

Adapted from upstream #4072 (cherry picked from commit 63106dbf57e749011ca70406affda8bcb8f9cfda);
the fork's tests live inline in lightroom_catalog.rs, so they were ported there.

Co-authored-by: THEtheChad <THEtheChad@users.noreply.github.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@THEtheChad THEtheChad changed the title Issue #4071: a refused Lightroom photo whose id is 0 refuses only itself A refused Lightroom photo with id 0 no longer skips every master Nov 17, 2026

@vangel76 vangel76 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 63106dbf. No findings. I traced the refused-ID guard through original and virtual-copy mapping and checked the zero sentinel and genuinely refused master cases.

Source review only. I did not build the project, run tests, or check CI.

@wanikhawar wanikhawar mentioned this pull request Dec 1, 2026
3 of 32 tasks

@wanikhawar wanikhawar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks right. masterImage is 0 for every master, so master != 0 is the correct guard, and it matches the one refuse_non_media already has in the same file. The tests cover id 0 with and without a virtual copy, plus a copy of a refused original.

Merge note: #3142 and #1735 carry the same guard, so whichever lands second drops the duplicate hunk.

I'm tracking this for v0.22.1 in #4964.

This branch has not been deployed

No deployments
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.

Lightroom import: a refused photo whose id is 0 makes the import skip every other photo's catalog data

3 participants