Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ internal static class ToolManifestFinderExtensions
public static (FilePath? filePath, string warningMessage) ExplicitManifestOrFindManifestContainPackageId(
this IToolManifestFinder toolManifestFinder,
string explicitManifestFile,
PackageId packageId)
PackageId packageId,
bool throwIfNoManifestFound = true)
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

warningMessage is declared as non-nullable (string) in the tuple return type, but this method returns null for it in several paths (explicit manifest, no match, and now the no-manifest catch). This makes the nullability contract incorrect for nullable-enabled callers and can lead to missed null checks / NRT warnings. Consider enabling nullable for this file (or at least for this method) and changing the signature to return string? warningMessage (and likewise accept string? explicitManifestFile).

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed the nullability annotations:

  • Removed #nullable disable from ToolManifestFinderExtensions.cs
  • Changed return type to (FilePath? filePath, string? warningMessage)
  • Changed parameter to string? explicitManifestFile
  • Updated calling code in ToolInstallLocalCommand.cs to use string?

All tests pass (21 install + 9 uninstall).

Commit: 4921020

{
if (!string.IsNullOrWhiteSpace(explicitManifestFile))
{
Expand All @@ -29,7 +30,11 @@ public static (FilePath? filePath, string warningMessage) ExplicitManifestOrFind
}
catch (ToolManifestCannotBeFoundException e)
{
throw new GracefulException([e.Message, CliCommandStrings.ToolCommonNoManifestGuide], verboseMessages: [e.VerboseMessage], isUserError: false);
if (throwIfNoManifestFound)
{
throw new GracefulException([e.Message, CliCommandStrings.ToolCommonNoManifestGuide], verboseMessages: [e.VerboseMessage], isUserError: false);
}
return (null, null);
}

if (manifestFilesContainPackageId.Any())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,15 @@ public override int Execute()

private int ExecuteInstallCommand(PackageId packageId, VersionRange? versionRange)
{
FilePath manifestFile = GetManifestFilePath();

(FilePath? manifestFileOptional, string warningMessage) =
_toolManifestFinder.ExplicitManifestOrFindManifestContainPackageId(_explicitManifestFile, packageId);
_toolManifestFinder.ExplicitManifestOrFindManifestContainPackageId(_explicitManifestFile, packageId, throwIfNoManifestFound: false);

if (warningMessage != null)
{
_reporter.WriteLine(warningMessage.Yellow());
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

In this nullable-enabled file, warningMessage is deconstructed as non-nullable string, but the called helper can return null for the warning. This forces a redundant warningMessage != null check (and can hide real nullability issues). After adjusting the helper’s signature, consider deconstructing into string? warningMessage here to match the actual behavior.

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was already addressed in commit 4921020. Line 105 now uses string? warningMessage to properly match the nullable return type from the helper method.

}

manifestFile = manifestFileOptional ?? GetManifestFilePath();
FilePath manifestFile = manifestFileOptional ?? GetManifestFilePath();
var existingPackageWithPackageId = _toolManifestFinder.Find(manifestFile).Where(p => p.PackageId.Equals(packageId));

if (!existingPackageWithPackageId.Any())
Expand Down
Loading