Skip to content

Save the best possible img from custom layout to standard (BL-16086)#7806

Open
JohnThomson wants to merge 1 commit intomasterfrom
saveBestCustomImgToStandard
Open

Save the best possible img from custom layout to standard (BL-16086)#7806
JohnThomson wants to merge 1 commit intomasterfrom
saveBestCustomImgToStandard

Conversation

@JohnThomson
Copy link
Copy Markdown
Contributor

@JohnThomson JohnThomson commented Apr 2, 2026


Open with Devin

This change is Reviewable

Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View 3 additional findings in Devin Review.

Open in Devin Review

Comment on lines +5231 to +5236
coverImgElt = GetCoverImageElt(outsideFrontCover);
if (coverImgElt == null)
return null;

return GetImagePath(coverImgElt);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🚩 Behavioral change: candidate selection no longer checks file existence on disk

The old GetCoverImagePathAndElt used GetImagePath() for candidate selection, which resolved paths against StoragePageFolder and checked RobustFile.Exists(). The new GetCoverImageElt uses GetImageSourceForCoverSelection() (Book.cs:5304-5311) which only reads DOM attributes. This means if the designated cover image has a valid-looking src but the file doesn't exist on disk, GetCoverImageElt will select that element, and then GetImagePath at Book.cs:5235 returns null — whereas the old code would have skipped it and tried the next candidate in the foreach loop. This affects all callers: CollectionApi.cs:710, BookMetadataApi.cs:56, BookCompressor.cs:48, PublishApi.cs:289, BookThumbNailer.cs:237, and Book.cs:5360. The scenario (designated image source is non-empty/non-placeholder but file missing, AND another valid candidate exists on the page) is very unlikely in practice, and DOM-based selection is more appropriate for the new BookData use case. Still, worth noting as a semantic change.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/BloomExe/Book/Book.cs">

<violation number="1" location="src/BloomExe/Book/Book.cs:5235">
P1: Behavioral regression: `GetCoverImageElt` selects elements based on whether the HTML source attribute is non-empty, but does not verify the referenced file exists on disk. The old inline code used `GetImagePath()` which checked file existence, so it would skip candidates with broken file references and fall through to other valid candidates. Now, if the best candidate's file is missing, `GetCoverImagePathAndElt` returns null instead of trying the next candidate.

Consider either (a) having `GetCoverImageElt` accept a file-existence predicate to skip broken references, or (b) adding a fallback loop in `GetCoverImagePathAndElt` that retries with the next-best candidate when `GetImagePath` returns null.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

if (coverImgElt == null)
return null;

return GetImagePath(coverImgElt);
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Apr 2, 2026

Choose a reason for hiding this comment

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

P1: Behavioral regression: GetCoverImageElt selects elements based on whether the HTML source attribute is non-empty, but does not verify the referenced file exists on disk. The old inline code used GetImagePath() which checked file existence, so it would skip candidates with broken file references and fall through to other valid candidates. Now, if the best candidate's file is missing, GetCoverImagePathAndElt returns null instead of trying the next candidate.

Consider either (a) having GetCoverImageElt accept a file-existence predicate to skip broken references, or (b) adding a fallback loop in GetCoverImagePathAndElt that retries with the next-best candidate when GetImagePath returns null.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/BloomExe/Book/Book.cs, line 5235:

<comment>Behavioral regression: `GetCoverImageElt` selects elements based on whether the HTML source attribute is non-empty, but does not verify the referenced file exists on disk. The old inline code used `GetImagePath()` which checked file existence, so it would skip candidates with broken file references and fall through to other valid candidates. Now, if the best candidate's file is missing, `GetCoverImagePathAndElt` returns null instead of trying the next candidate.

Consider either (a) having `GetCoverImageElt` accept a file-existence predicate to skip broken references, or (b) adding a fallback loop in `GetCoverImagePathAndElt` that retries with the next-best candidate when `GetImagePath` returns null.</comment>

<file context>
@@ -5228,6 +5228,18 @@ public string GetCoverImagePathAndElt(out SafeXmlElement coverImgElt)
+            if (coverImgElt == null)
+                return null;
+
+            return GetImagePath(coverImgElt);
+        }
+
</file context>
Fix with Cubic

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.

1 participant