Skip to content

Skip a Lightroom image whose file, folder or root reference isn't an id - #4097

Draft
THEtheChad wants to merge 1 commit into
storytold:mainfrom
THEtheChad:fix/lr-path-record-id
Draft

THEtheChad wants to merge 1 commit into
storytold:mainfrom
THEtheChad:fix/lr-path-record-id

Conversation

@THEtheChad

@THEtheChad THEtheChad commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #4094

Problem

The reader finds an image's original through Adobe_images.rootFile → AgLibraryFile.folder → AgLibraryFolder.rootFolder. It read all three with number(), which turns a missing, NULL or text value into 0 and truncates 1.5 to 1. So an image with a bad reference took the path of record 0, or of record 1 for 1.5. When that path was another image's original, the two imported as one photo, and the later image overwrote the first one's rating and catalog data without a warning. This was reproduced with crafted catalogs; whether Lightroom writes such references hasn't been established.

Change

crates/engine/src/lightroom_catalog.rs:

  • New id_of(row, column) reads a reference as a whole number. It returns None for a missing, NULL, text, fractional or out-of-i64-range value. Integers go through f64 the same way id_local does, so ids past 2^53 still match.
  • read_file resolves the three references through id_of. A bad one skips the image with the existing reason, missingFile, missingFolder or missingRoot, and the image's virtual copies go with it.
  • The SkipReason docs and docs/lightroom-catalog-import.md say so. A literal 0 still names record 0, and a whole REAL 1.0 names record 1.

Tests

New in lightroom_catalog/tests.rs: an_image_whose_path_reference_is_not_a_whole_number_is_skipped (12 cases), an_image_naming_no_file_does_not_merge_into_the_photo_of_file_0 and a_reference_names_a_record_only_by_a_whole_number. On main's file, with only id_of added, the first two fail (104 passed, 2 failed). Reverting any one of the three lines fails its four cases.

cargo xtask ci passed all 9 steps on 1f850ac (on main c2e9c45). With lightcraft-cli on crafted catalogs, main merges the bad image into another photo and changes its rating; this branch skips it. Well-formed catalogs, with ids past 2^53 or REAL 1.0 references, import as on main. The desktop app was not run.

Notes

…is not an id is skipped

Adobe_images.rootFile, AgLibraryFile.folder and AgLibraryFolder.rootFolder were read with number(), which reads a NULL, text or non-finite value as 0 and truncates 1.5 to 1. An image with such a reference took the path of the record with that id and merged into its photo, replacing that photo's rating and catalog data. They are now read as whole numbers (id_of); an image whose reference names no record is skipped as missingFile, missingFolder or missingRoot.
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Lightroom importer now accepts path references only when they represent whole-number IDs. Invalid references produce the corresponding missing-record skip reason instead of resolving to another record. Tests and documentation cover the change.

Changes: Lightroom path reference resolution

Layer / File(s) Summary
Validate catalog path references
crates/engine/src/lightroom_catalog.rs, docs/lightroom-catalog-import.md
A new conversion function rejects absent, nonnumeric, fractional, and out-of-range IDs. File, folder, and root lookups use it. Invalid references produce the corresponding missing-record reason, as documented.
Test malformed references
crates/engine/src/lightroom_catalog/tests.rs
SQLite fixtures now support real and blob values and explicit rowids. Tests cover accepted and rejected ID values, malformed path references, and an import case where a null root reference previously could resolve to file ID 0.

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

Change: Bug fix · Severity of issue fixed: Medium

Possibly related issues

  • Issue 4089: This change validates image path references, but does not change conversion of side-table image references.
  • Issue 4095: This change does not alter conversion of collection-member collection references.

Suggested reviewers: aiongg

Merge Risk: Minimal · up to 1f850

The reference-validation change is mergeable after normal checks; no actionable issue remains identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Linked Issues check Passed The PR satisfies #4094. id_of accepts only whole-number references within i64 range and preserves the existing f64 matching behavior. read_file uses it for rootFile, folder, and rootFolder…
Out of Scope Changes check Passed The changes stay within #4094. The production change handles the three image-path references. The test-fixture changes support the required malformed-catalog tests. The SkipReason and import documen…
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: an image whose file, folder, or root reference is not an id is skipped. The raw summary and objectives confirm that invalid rootFile, folder, and rootFolder references…
Full details: Linked Issues check

Explanation

The PR satisfies #4094. id_of accepts only whole-number references within i64 range and preserves the existing f64 matching behavior. read_file uses it for rootFile, folder, and rootFolder. Invalid references therefore produce missingFile, missingFolder, or missingRoot and skip the image with its virtual copies. The tests cover NULL, text, fractions, record 0, f64 edge cases, and the former merge case. The documentation describes the new behavior.

Full details: Out of Scope Changes check

Explanation

The changes stay within #4094. The production change handles the three image-path references. The test-fixture changes support the required malformed-catalog tests. The SkipReason and import documentation changes explain the required behavior. No unrelated production feature, dependency, build, asset, or CI change is reported.

Full details: Title check

Explanation

The title names the main change: an image whose file, folder, or root reference is not an id is skipped. The raw summary and objectives confirm that invalid rootFile, folder, and rootFolder references now produce skips with the existing missing-record reasons, instead of resolving to another record. The title is specific and matches the changeset.

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 c2e9c45 and 1f850ac.

Files selected for processing: 3

  • crates/engine/src/lightroom_catalog.rs
  • crates/engine/src/lightroom_catalog/tests.rs
  • docs/lightroom-catalog-import.md

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
…e isn't an id is skipped

An image whose rootFile, folder or rootFolder reference was missing, NULL, text or a fraction
resolved to record 0 (or 1 for 1.5) and could merge into another photo. It is now skipped with
the existing missing-file/folder/root reasons. Generalises the #4090 image_of helper into id_of.
Hand-ported into the fork's reader; unit test for id_of added.

Adapted from upstream #4097 (head 1f850ace97)

Co-authored-by: THEtheChad <THEtheChad@users.noreply.github.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
1234destiny1234 referenced this pull request in 1234destiny1234/lightcraft-classic Nov 15, 2026
…an id joins no album

A member row whose collection was missing, NULL, text or a fraction joined collection 0 (or the
truncated id). It now joins no album, with one warning. Hand-ported into the fork's reader,
reusing the id_of helper from #4097; test added.

Adapted from upstream #4098 (head 85435de01f)

Co-authored-by: THEtheChad <THEtheChad@users.noreply.github.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@THEtheChad
THEtheChad marked this pull request as draft November 17, 2026 18:29
@THEtheChad THEtheChad changed the title Issue #4094: a Lightroom image whose file, folder or root folder reference isn't an id is skipped Skip a Lightroom image whose file, folder or root reference isn't an id Nov 17, 2026
@wanikhawar

Copy link
Copy Markdown
Contributor

This applies cleanly to main, and the strict id_of on rootFile, folder and rootFolder skips the image with the existing reason instead of merging it into record 0.

#4098 adds the same function and the same test name, and #4090 has image_of, which does the same job. Please settle which PR introduces the shared helper and have the others reuse it, so there is one copy and one test name. After that I have no objection.

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: an image whose file, folder or root folder reference isn't an id merges into another photo

2 participants