Skip to content

Fix argument null exception when updating plugin directories for erroneous plugins #3584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

Jack251970
Copy link
Contributor

If some plugins failed to construct, Name or AssemblyName property will not be initialized and could be null. This can cause this issue:


Please open new issue in https://github.com/Flow-Launcher/Flow.Launcher/issues
1. Upload log file: C:\Users\11602\AppData\Roaming\FlowLauncher\Logs\1.20.0\2025-05-24.txt
2. Copy below exception message

Flow Launcher version: 1.20.0
OS Version: 26100.4061
IntPtr Length: 8
x64: True

Python Path: C:\Users\11602\AppData\Roaming\FlowLauncher\Environments\Python\PythonEmbeddable-v3.11.4\pythonw.exe
Node Path: C:\Program Files\nodejs\node.exe

Date: 05/24/2025 22:45:22
Exception:
System.ArgumentNullException: Value cannot be null. (Parameter 'path2')
   at System.ArgumentNullException.Throw(String paramName)
   at System.IO.Path.Combine(String path1, String path2)
   at Flow.Launcher.Core.Plugin.PluginManager.UpdatePluginDirectory(List`1 metadatas) in C:\projects\flow-launcher\Flow.Launcher.Core\Plugin\PluginManager.cs:line 190
   at Flow.Launcher.Core.Plugin.PluginManager.LoadPlugins(PluginsSettings settings) in C:\projects\flow-launcher\Flow.Launcher.Core\Plugin\PluginManager.cs:line 181
   at Flow.Launcher.App.<OnStartup>b__14_0() in C:\projects\flow-launcher\Flow.Launcher\App.xaml.cs:line 187
   at Flow.Launcher.Infrastructure.Stopwatch.InfoAsync(String className, String message, Func`1 action, String methodName) in C:\projects\flow-launcher\Flow.Launcher.Infrastructure\Stopwatch.cs:line 53
   at Flow.Launcher.App.OnStartup(Object sender, StartupEventArgs e) in C:\projects\flow-launcher\Flow.Launcher\App.xaml.cs:line 161
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

So we need to check it when updating plugin directories for erroneous plugins.

@prlabeler prlabeler bot added the bug Something isn't working label May 25, 2025
@Jack251970 Jack251970 enabled auto-merge May 25, 2025 01:16
@Jack251970 Jack251970 added Dev branch only An issue or fix for the Dev branch build and removed bug Something isn't working labels May 25, 2025
@Jack251970 Jack251970 requested a review from Copilot May 25, 2025 01:17
@Jack251970 Jack251970 added this to the 1.20.0 milestone May 25, 2025

This comment has been minimized.

Copy link

gitstream-cm bot commented May 25, 2025

🥷 Code experts: no user but you matched threshold 10

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

See details

Flow.Launcher.Core/Plugin/PluginManager.cs

Activity based on git-commit:

Jack251970
MAY 75 additions & 21 deletions
APR 73 additions & 68 deletions
MAR 42 additions & 37 deletions
FEB 276 additions & 198 deletions
JAN 5 additions & 5 deletions
DEC

Knowledge based on git-blame:
Jack251970: 32%
VictoriousRaptor: 17%

To learn more about /:\ gitStream - Visit our Docs

Copy link

gitstream-cm bot commented May 25, 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

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds null-or-empty checks for plugin identifiers to prevent ArgumentNullException when constructing plugin directory paths for plugins with missing metadata.

  • Skip updating directory paths if AssemblyName or Name is null/empty
  • Prevents Path.Combine failures for erroneous plugins
Comments suppressed due to low confidence (2)

Flow.Launcher.Core/Plugin/PluginManager.cs:190

  • Consider adding unit tests to verify that UpdatePluginDirectory correctly skips plugins when AssemblyName or Name is null or empty.
if (string.IsNullOrEmpty(metadata.AssemblyName))

Flow.Launcher.Core/Plugin/PluginManager.cs:194

  • [nitpick] These two language-specific branches duplicate similar logic for combining paths. Consider extracting the identifier (AssemblyName or Name) and the combine logic into a helper to reduce duplication.
metadata.PluginSettingsDirectoryPath = Path.Combine(DataLocation.PluginSettingsDirectory, metadata.AssemblyName);

Copy link

gitstream-cm bot commented May 25, 2025

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

This comment has been minimized.

Copy link
Contributor

coderabbitai bot commented May 25, 2025

📝 Walkthrough

Walkthrough

Validation checks were added in the UpdatePluginDirectory method to ensure that plugin directory paths are only set for plugins with valid identifiers. The method now logs warnings and skips processing for plugins missing essential fields, preventing erroneous plugin metadata from being handled.

Changes

File(s) Change Summary
Flow.Launcher.Core/Plugin/PluginManager.cs Added validation to UpdatePluginDirectory to skip and log plugins with missing identifiers.

Suggested labels

bug

Suggested reviewers

  • jjw24

Poem

A plugin path, a careful check,
No more errors to bedeck.
Warnings logged, the way is clear,
Only valid plugins here!
With every hop, the code grows bright—
Bugs beware, we set it right!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Jack251970 Jack251970 requested a review from Copilot May 25, 2025 01:18
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses the ArgumentNullException issue when updating plugin directories by adding null or empty checks for the AssemblyName and Name properties of PluginMetadata.

  • Skips updating directories for plugins with an empty AssemblyName (for .NET plugins)
  • Skips updating directories for plugins with an empty Name (for non-.NET plugins)

Jack251970 and others added 2 commits May 25, 2025 09:19
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

This comment has been minimized.

This comment has been minimized.

@Jack251970 Jack251970 requested review from Copilot and jjw24 May 25, 2025 01:21
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR prevents ArgumentNullException in UpdatePluginDirectory by skipping plugins whose AssemblyName or Name is null or empty.

  • Add string.IsNullOrEmpty checks for metadata.AssemblyName (for .NET plugins) and metadata.Name (for non-.NET plugins)
  • Log a warning and continue to skip directory updates for those erroneous plugins
Comments suppressed due to low confidence (3)

Flow.Launcher.Core/Plugin/PluginManager.cs:192

  • [nitpick] The warning message logs metadata.Name, which may also be empty. Consider including a different identifier (e.g., plugin file path or ID) so the logged warning is more informative.
API.LogWarn(ClassName, $"AssemblyName is empty for plugin with metadata: {metadata.Name}");

Flow.Launcher.Core/Plugin/PluginManager.cs:190

  • This new null-check logic should be covered by unit tests to verify that plugins with empty AssemblyName or Name are skipped gracefully without exceptions.
if (string.IsNullOrEmpty(metadata.AssemblyName))

Flow.Launcher.Core/Plugin/PluginManager.cs:195

  • [nitpick] The directory assignment logic is duplicated in both branches. Consider extracting the common logic into a helper method or local function to reduce duplication.
metadata.PluginSettingsDirectoryPath = Path.Combine(DataLocation.PluginSettingsDirectory, metadata.AssemblyName);

Copy link

@check-spelling-bot Report

🔴 Please review

See the 📂 files view, the 📜action log, or 📝 job summary for details.

❌ Errors and Warnings Count
❌ forbidden-pattern 22
⚠️ non-alpha-in-dictionary 13

See ❌ Event descriptions for more information.

If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

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: 0

🧹 Nitpick comments (1)
Flow.Launcher.Core/Plugin/PluginManager.cs (1)

200-204: Improve log message for better debugging when Name is null/empty.

The null check logic is correct and consistent with the .NET plugin validation. However, the log message could be more informative when metadata.Name is null or empty.

Consider this improvement for clearer debugging:

-                        API.LogWarn(ClassName, $"Name is empty for plugin with metadata: {metadata.Name}");
+                        API.LogWarn(ClassName, $"Name is empty for plugin with metadata: {metadata.Name ?? "<null>"}");

Or alternatively, provide more context:

-                        API.LogWarn(ClassName, $"Name is empty for plugin with metadata: {metadata.Name}");
+                        API.LogWarn(ClassName, $"Plugin Name is null or empty, skipping directory setup. Plugin directory: {metadata.PluginDirectory}");
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6333cd3 and 50780db.

📒 Files selected for processing (1)
  • Flow.Launcher.Core/Plugin/PluginManager.cs (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
Flow.Launcher.Core/Plugin/PluginManager.cs (3)
Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs (1)
  • LogWarn (270-270)
Flow.Launcher/PublicAPIInstance.cs (1)
  • LogWarn (271-272)
Flow.Launcher.Core/Plugin/JsonRPCV2Models/JsonRPCPublicAPI.cs (1)
  • LogWarn (153-156)
🪛 GitHub Actions: Check Spelling
Flow.Launcher.Core/Plugin/PluginManager.cs

[warning] 39-55: metadatas is not a recognized word. (unrecognized-spelling)


[warning] 114-133: Reloadable is not a recognized word. (unrecognized-spelling)


[warning] 176-193: metadatas is not a recognized word. (unrecognized-spelling)


[warning] 178-231: metadatas is not a recognized word. (unrecognized-spelling)


[warning] 179-238: metadatas is not a recognized word. (unrecognized-spelling)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
  • GitHub Check: build
🔇 Additional comments (1)
Flow.Launcher.Core/Plugin/PluginManager.cs (1)

190-194: LGTM! Effective null check prevents ArgumentNullException.

The validation correctly prevents the ArgumentNullException that would occur when Path.Combine receives null values in lines 195-196. The logging provides useful debugging information and the graceful skip behavior is appropriate for handling erroneous plugins.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 min review Dev branch only An issue or fix for the Dev branch build
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant