Skip to content

Conversation

dcog989
Copy link
Contributor

@dcog989 dcog989 commented Sep 12, 2025

Catch an exception for empty / corrupted favicons.

This is just a quick fix until I complete a rewrite of this plugin which will properly fix this issue.

Catch an exception for empty / corrupted favicons.
@prlabeler prlabeler bot added the bug Something isn't working label Sep 12, 2025
@github-actions github-actions bot added this to the 2.1.0 milestone Sep 12, 2025
Copy link

gitstream-cm bot commented Sep 12, 2025

🥷 Code experts: Jack251970, jjw24

Jack251970, jjw24 have most 👩‍💻 activity in the files.
Jack251970 has most 🧠 knowledge in the files.

See details

Plugins/Flow.Launcher.Plugin.BrowserBookmark/Helper/FaviconHelper.cs

Activity based on git-commit:

Jack251970 jjw24
SEP
AUG
JUL 1 additions & 1 deletions
JUN 81 additions & 5 deletions 76 additions & 0 deletions
MAY
APR

Knowledge based on git-blame:
Jack251970: 56%

✨ Comment /gs review for LinearB AI review. Learn how to automate it here.

Copy link

gitstream-cm bot commented Sep 12, 2025

Be a legend 🏆 by adding a before and after screenshot of the changes you made, especially if they are around UI/UX.

Copy link
Contributor

coderabbitai bot commented Sep 12, 2025

📝 Walkthrough

Walkthrough

Refactors FaviconHelper.TryConvertToWebp to use using var disposals, adds a null-check after creating an SKImage from a bitmap, retains WebP encoding at quality 65, returns encoded bytes on success or null otherwise, and preserves bitmap disposal in finally.

Changes

Cohort / File(s) Summary
Favicon WebP encoding safety
Plugins/Flow.Launcher.Plugin.BrowserBookmark/Helper/FaviconHelper.cs
Replaced nested using blocks with using var, added null-check for SKImage.FromBitmap, kept WebP encode (quality 65), return null on failure, ensured proper disposal of bitmap, image, and stream.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • Jack251970
  • jjw24

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly summarizes the primary change: adding handling for empty or broken favicons. It accurately reflects the modifications in FaviconHelper (null-checks and safer image handling) and aligns with the PR objectives. The phrasing is concise and clear for reviewers scanning history.
Description Check ✅ Passed The description directly states that the PR catches an exception for empty/corrupted favicons and notes it is a temporary quick fix pending a plugin rewrite, which matches the code changes and PR objectives. It gives relevant context for reviewers despite being brief.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
Plugins/Flow.Launcher.Plugin.BrowserBookmark/Helper/FaviconHelper.cs (2)

79-92: Dispose SKSvg and avoid 0x0 bitmap creation for empty SVGs

This prevents a small leak and avoids constructing invalid SKBitmaps when the SVG cull rect is empty.

-            using (var ms = new MemoryStream(data))
-            {
-                var svg = new SKSvg();
-                if (svg.Load(ms) != null && svg.Picture != null)
-                {
-                    bitmap = new SKBitmap((int)svg.Picture.CullRect.Width, (int)svg.Picture.CullRect.Height);
-                    using (var canvas = new SKCanvas(bitmap))
-                    {
-                        canvas.Clear(SKColors.Transparent);
-                        canvas.DrawPicture(svg.Picture);
-                        canvas.Flush();
-                    }
-                }
-            }
+            using (var ms = new MemoryStream(data))
+            {
+                using var svg = new SKSvg();
+                if (svg.Load(ms) != null && svg.Picture != null)
+                {
+                    var cull = svg.Picture.CullRect;
+                    var w = (int)Math.Ceiling(cull.Width);
+                    var h = (int)Math.Ceiling(cull.Height);
+                    if (w > 0 && h > 0)
+                    {
+                        bitmap = new SKBitmap(w, h);
+                        using var canvas = new SKCanvas(bitmap);
+                        canvas.Clear(SKColors.Transparent);
+                        canvas.DrawPicture(svg.Picture);
+                    }
+                }
+            }

60-67: Pre-create the output directory to avoid DirectoryNotFoundException

Minor robustness tweak before writing bytes.

         try
         {
+            var dir = Path.GetDirectoryName(outputPath);
+            if (!string.IsNullOrEmpty(dir))
+                Directory.CreateDirectory(dir);
             File.WriteAllBytes(outputPath, imageData);
         }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b898c46 and 15f31a1.

📒 Files selected for processing (1)
  • Plugins/Flow.Launcher.Plugin.BrowserBookmark/Helper/FaviconHelper.cs (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: Jack251970
PR: Flow-Launcher/Flow.Launcher#3897
File: Flow.Launcher/ViewModel/PluginViewModel.cs:46-51
Timestamp: 2025-08-13T06:12:43.382Z
Learning: In Flow Launcher's PluginViewModel.cs, the LoadIconAsync method does not require additional try-catch error handling according to maintainer Jack251970, as the existing error handling approach is considered sufficient for the image loading operations.
📚 Learning: 2025-08-13T06:12:43.382Z
Learnt from: Jack251970
PR: Flow-Launcher/Flow.Launcher#3897
File: Flow.Launcher/ViewModel/PluginViewModel.cs:46-51
Timestamp: 2025-08-13T06:12:43.382Z
Learning: In Flow Launcher's PluginViewModel.cs, the LoadIconAsync method does not require additional try-catch error handling according to maintainer Jack251970, as the existing error handling approach is considered sufficient for the image loading operations.

Applied to files:

  • Plugins/Flow.Launcher.Plugin.BrowserBookmark/Helper/FaviconHelper.cs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: gitStream.cm
  • GitHub Check: build

Copy link
Member

@Jack251970 Jack251970 left a comment

Choose a reason for hiding this comment

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

LGTM

@Jack251970 Jack251970 merged commit 889ed58 into Flow-Launcher:dev Sep 13, 2025
9 checks passed
@dcog989 dcog989 deleted the bookmark-quick-fix branch September 13, 2025 11:03
@jjw24 jjw24 modified the milestones: 2.1.0, 2.0.1 Sep 21, 2025
jjw24 pushed a commit that referenced this pull request Sep 21, 2025
Bookmark plugin - catch an exception for empty / broken favicons
@jjw24 jjw24 mentioned this pull request Sep 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants