Skip to content

Conversation

dcog989
Copy link
Contributor

@dcog989 dcog989 commented Sep 13, 2025

Rather than showing the user EXCEPTION OCCURS: System.Threading.Tasks.TaskCanceledException..., print not scary log msg

Rather than showing the user `EXCEPTION OCCURS: System.Threading.Tasks.TaskCanceledException...`, print not scary log msg
@github-actions github-actions bot added this to the 2.1.0 milestone Sep 13, 2025
Copy link

gitstream-cm bot commented Sep 13, 2025

🥷 Code experts: Jack251970

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

See details

Flow.Launcher.Core/ExternalPlugins/CommunityPluginSource.cs

Activity based on git-commit:

Jack251970
SEP
AUG
JUL
JUN
MAY
APR 61 additions & 39 deletions

Knowledge based on git-blame:
Jack251970: 50%

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

Copy link

gitstream-cm bot commented Sep 13, 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 13, 2025

📝 Walkthrough

Walkthrough

Adds explicit cancellation handling in FetchAsync of CommunityPluginSource: catches OperationCanceledException (when token requested) and TaskCanceledException, logs and returns null; existing HTTP-status handling and generic exception catch remain unchanged. No public API changes. (≈34 words)

Changes

Cohort / File(s) Summary
Cancellation handling in fetch
Flow.Launcher.Core/ExternalPlugins/CommunityPluginSource.cs
Add dedicated catches in FetchAsync for OperationCanceledException (when token.IsCancellationRequested) and TaskCanceledException; log cancellation/timeout and return null. Preserve existing OK/NotModified/other HTTP status handling and generic catch (Exception) behavior.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Caller
  participant CommunityPluginSource as CommunityPluginSource.FetchAsync
  participant HttpClient

  Caller->>CommunityPluginSource: FetchAsync(ct)
  CommunityPluginSource->>HttpClient: send request (with ct)
  alt Request completes
    HttpClient-->>CommunityPluginSource: Response (200/304/other)
    CommunityPluginSource-->>Caller: result per status handling
  else Cancelled by token
    HttpClient-->>CommunityPluginSource: throws OperationCanceledException
    rect #E8F5E9
      Note right of CommunityPluginSource: Catch OperationCanceledException\nLog info\nReturn null
    end
    CommunityPluginSource-->>Caller: null
  else HttpClient timeout or external cancel
    HttpClient-->>CommunityPluginSource: throws TaskCanceledException
    rect #FFF3E0
      Note right of CommunityPluginSource: Catch TaskCanceledException\nLog warn\nReturn null
    end
    CommunityPluginSource-->>Caller: null
  else Other error
    HttpClient-->>CommunityPluginSource: throws Exception
    rect #FFEBEE
      Note right of CommunityPluginSource: Generic catch\nLog error\nHandle/return null
    end
    CommunityPluginSource-->>Caller: null or error result
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • jjw24

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly summarizes the primary change—replacing an alarming exception message with a friendlier log—and is concise, specific to the PR intent, and easily understood by a teammate scanning history.
Description Check ✅ Passed The description directly describes the changeset goal by stating that raw TaskCanceledException output will be replaced with a less alarming log message, so it is on-topic and satisfies the lenient description check.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6eeef62 and 08a571f.

📒 Files selected for processing (1)
  • Flow.Launcher.Core/ExternalPlugins/CommunityPluginSource.cs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Flow.Launcher.Core/ExternalPlugins/CommunityPluginSource.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). (3)
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
  • GitHub Check: build

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.

@coderabbitai coderabbitai bot added the bug Something isn't working label Sep 13, 2025
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)
Flow.Launcher.Core/ExternalPlugins/CommunityPluginSource.cs (2)

46-49: Dispose request and avoid sending an empty If-None-Match header

Minor cleanup: dispose HttpRequestMessage and only add the ETag header when present to prevent invalid/empty header values.

-            var request = new HttpRequestMessage(HttpMethod.Get, ManifestFileUrl);
-
-            request.Headers.Add("If-None-Match", latestEtag);
+            using var request = new HttpRequestMessage(HttpMethod.Get, ManifestFileUrl);
+            if (!string.IsNullOrWhiteSpace(latestEtag))
+                request.Headers.Add("If-None-Match", latestEtag);

57-63: Guard against null deserialization result to prevent NRE

ReadFromJsonAsync can return null; using plugins.Count immediately after may throw. Default to an empty list.

-                    plugins = await response.Content
-                        .ReadFromJsonAsync<List<UserPlugin>>(PluginStoreItemSerializationOption, cancellationToken: token)
-                        .ConfigureAwait(false);
+                    var deserialized = await response.Content
+                        .ReadFromJsonAsync<List<UserPlugin>>(PluginStoreItemSerializationOption, cancellationToken: token)
+                        .ConfigureAwait(false);
+                    plugins = deserialized ?? new List<UserPlugin>();
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eaa90b3 and 6eeef62.

📒 Files selected for processing (1)
  • Flow.Launcher.Core/ExternalPlugins/CommunityPluginSource.cs (1 hunks)
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: Jack251970
PR: Flow-Launcher/Flow.Launcher#3572
File: Flow.Launcher/App.xaml.cs:214-216
Timestamp: 2025-07-06T12:21:37.947Z
Learning: In Flow Launcher, the UpdatePluginManifestAsync method in PluginsManifest.cs already has comprehensive internal try-catch handling that logs exceptions and returns false on failure rather than throwing, making external try-catch wrappers unnecessary.
📚 Learning: 2025-07-06T12:21:37.947Z
Learnt from: Jack251970
PR: Flow-Launcher/Flow.Launcher#3572
File: Flow.Launcher/App.xaml.cs:214-216
Timestamp: 2025-07-06T12:21:37.947Z
Learning: In Flow Launcher, the UpdatePluginManifestAsync method in PluginsManifest.cs already has comprehensive internal try-catch handling that logs exceptions and returns false on failure rather than throwing, making external try-catch wrappers unnecessary.

Applied to files:

  • Flow.Launcher.Core/ExternalPlugins/CommunityPluginSource.cs
📚 Learning: 2025-07-21T09:19:49.684Z
Learnt from: Jack251970
PR: Flow-Launcher/Flow.Launcher#3854
File: Flow.Launcher/App.xaml.cs:246-262
Timestamp: 2025-07-21T09:19:49.684Z
Learning: In Flow Launcher's App.xaml.cs, the asynchronous plugin initialization task (containing AbstractPluginEnvironment.PreStartPluginExecutablePathUpdate, PluginManager.LoadPlugins, PluginManager.InitializePluginsAsync, and AutoPluginUpdates) does not require additional try-catch error handling according to maintainer Jack251970, as these operations are designed to handle exceptions internally.

Applied to files:

  • Flow.Launcher.Core/ExternalPlugins/CommunityPluginSource.cs
📚 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:

  • Flow.Launcher.Core/ExternalPlugins/CommunityPluginSource.cs
📚 Learning: 2025-07-21T09:19:19.012Z
Learnt from: Jack251970
PR: Flow-Launcher/Flow.Launcher#3854
File: Flow.Launcher.Core/Plugin/PluginManager.cs:280-292
Timestamp: 2025-07-21T09:19:19.012Z
Learning: In Flow Launcher's PluginManager.cs, the post-initialization operations (RegisterResultsUpdatedEvent, UpdatePluginMetadataTranslation, RegisterPluginActionKeywords, DialogJump.InitializeDialogJumpPlugin, and AddPluginToLists) are designed to be exception-safe and do not require additional try-catch error handling according to the maintainer Jack251970.

Applied to files:

  • Flow.Launcher.Core/ExternalPlugins/CommunityPluginSource.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

@Jack251970 Jack251970 merged commit 0e0ef0e into Flow-Launcher:dev Sep 14, 2025
8 checks passed
@Jack251970
Copy link
Member

@dcog989 Thanks for your contribution!

@dcog989 dcog989 deleted the CommunityPluginSource-logging-refined branch September 14, 2025 13:17
@dcog989 dcog989 restored the CommunityPluginSource-logging-refined branch September 18, 2025 13:06
@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
…efined

Catch scary exception, print friendly log
@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