Skip to content
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

Add support for DisplayInstallWarnings #2217

Closed
wants to merge 7 commits into from

Conversation

ryfu-msft
Copy link
Contributor

@ryfu-msft ryfu-msft commented Jun 3, 2022

Resolves #1786

Changes:

  • Adds support for prompting the user with a warning message if the DisplayInstallWarnings field is set to true. The message notifies the user that the installer may interfere with running applications
  • Added --ignore-warnings flag to allow users to override the default behavior of warning prompts

Tests:

  • Added unit tests to verify that prompts are called correctly with the right message.
Microsoft Reviewers: Open in CodeFlow

@ryfu-msft ryfu-msft requested a review from a team as a code owner June 3, 2022 22:30
@ghost ghost added Area-Manifest This may require a change to the manifest Issue-Feature This is a feature request for the Windows Package Manager client. labels Jun 3, 2022
@yao-msft
Copy link
Contributor

yao-msft commented Jun 3, 2022

This change will probably block com callers with packages having warnings. We need to expose something in InstallOptions in Com interface

@@ -97,6 +97,8 @@ namespace AppInstaller::CLI
return Argument{ "wait", NoAlias, Args::Type::Wait, Resource::String::WaitArgumentDescription, ArgumentType::Flag, false };
case Args::Type::ProductCode:
return Argument{ "product-code", NoAlias, Args::Type::ProductCode, Resource::String::ProductCodeArgumentDescription, ArgumentType::Standard, false };
case Args::Type::IgnoreWarnings:
return Argument{ "ignore-warnings", NoAlias, Args::Type::IgnoreWarnings, Resource::String::IgnoreWarningsArgumentDescription, ArgumentType::Flag, false };
Copy link
Contributor

@yao-msft yao-msft Jun 3, 2022

Choose a reason for hiding this comment

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

nit: I think "ignore-install-warnings" would be more accurate, "ignore-warnings" seems too generic. Also please update the variable name to leave room for future warnings

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think "ignore-install-warnings" would be more accurate, "ignore-warnings" seems too generic. Also please update the variable name to leave room for future warnings

Also you'll need to expose them in each applicable command.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this might be getting back more to the root issue that --force (specifically for Hash Overrides and other actions with security concerns) should be changed to be less generic. As a user, I would expect that --force would act as a general ignore warnings, especially so in this case.

I know that it would likely be a breaking change, but just throwing my thoughts here so @denelon can assess if / when it may be appropriate to make that change, given that it has implications on implementation of other features such as this one

Copy link
Contributor

Choose a reason for hiding this comment

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

I've seen a couple of features reported with similar concerns like:

I just added it to:

Copy link
Member

Choose a reason for hiding this comment

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

Breaking or not, we should change --force per this discussion: #2112

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to ignore-install-warnings and expose the option in the install and upgrade commands

@@ -1349,4 +1349,10 @@ Please specify one of them using the `--source` option to proceed.</value>
<data name="ShowLabelInstallationNotes" xml:space="preserve">
<value>InstallationNotes:</value>
</data>
<data name="IgnoreWarningsArgumentDescription" xml:space="preserve">
<value>Disables warning prompts</value>
Copy link
Contributor

Choose a reason for hiding this comment

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

Disables warning prompts

nit: Disables install warning prompts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to Disables install warnings

Copy link
Contributor

@yao-msft yao-msft left a comment

Choose a reason for hiding this comment

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

🕐

@ghost ghost added the Needs-Author-Feedback Issue needs attention from issue or PR author label Jun 4, 2022
@yao-msft
Copy link
Contributor

yao-msft commented Jun 6, 2022

Since this field is per installer level, maybe for better user experience, shall we change the installer selection logic to pick installers without warnings over warnings?

@Trenly
Copy link
Contributor

Trenly commented Jun 7, 2022

Since this field is per installer level, maybe for better user experience, shall we change the installer selection logic to pick installers without warnings over warnings?

I would say no - I wouldn't want winget to select an x86 installer for a x64 system if the x64 installer had installer warnings. Similarly, I wouldn't want the warnings to change a user scoped installation to a machine scoped installation, just because the machine scope didn't have warnings. I could see adding a setting to always suppress the warnings, but I don't think that changing the selection behavior based on a warning is a good idea, since it isn't a guarantee that the application is running when the user attempts the upgrade

@yao-msft
Copy link
Contributor

yao-msft commented Jun 7, 2022

Since this field is per installer level, maybe for better user experience, shall we change the installer selection logic to pick installers without warnings over warnings?

I would say no - I wouldn't want winget to select an x86 installer for a x64 system if the x64 installer had installer warnings. Similarly, I wouldn't want the warnings to change a user scoped installation to a machine scoped installation, just because the machine scope didn't have warnings. I could see adding a setting to always suppress the warnings, but I don't think that changing the selection behavior based on a warning is a good idea, since it isn't a guarantee that the application is running when the user attempts the upgrade

I agree, the installer selection logic actually has different levels of priority when determining which installer to pick, the priority of the InstallWarnings should always be in the lowest. Only when 2 installers have same scope, arch etc would the InstallWarnings be considered a factor. But given how rare this would be, I'm ok with not implementing anything. Just throwing some thought out.

Copy link
Member

@JohnMcPMS JohnMcPMS left a comment

Choose a reason for hiding this comment

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

I don't think that this feature has been though through enough. I would expect that many upgrades affect their own package, which is in line with the current message of "interfering with running applications". So the flag is added, then nearly every package prompts you?

I get that it is painful if running an installer messes with active processes, but I don't think this is the right way to deal with that.


if (displayInstallWarnings && !context.Args.Contains(Execution::Args::Type::IgnoreWarnings) && !Settings::User().Get<Settings::Setting::InstallIgnoreWarnings>())
{
bool ignoreWarning = context.Reporter.PromptForBoolResponse(Resource::String::InstallWarning);
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure what the use case is here, but I don't like prompting on a warning. At a minimum I would think that the setting should be ignore/display/prompt with the default being display.

ignore = Don't show them at all
display = Display the warning once the installer is chosen (before download) which gives an interactive user a fair amount of time to react with CTRL+C
prompt = This behavior of prompting after displaying the warnings.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that not prompting is better, especially knowing that WinGet is used in many autonomous install/upgrade scenarios

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed settings to take in an enum for installWarning level with ignore, display, and prompt as the possible values. Changed install warning behavior as suggested

@@ -97,6 +97,8 @@ namespace AppInstaller::CLI
return Argument{ "wait", NoAlias, Args::Type::Wait, Resource::String::WaitArgumentDescription, ArgumentType::Flag, false };
case Args::Type::ProductCode:
return Argument{ "product-code", NoAlias, Args::Type::ProductCode, Resource::String::ProductCodeArgumentDescription, ArgumentType::Standard, false };
case Args::Type::IgnoreWarnings:
return Argument{ "ignore-warnings", NoAlias, Args::Type::IgnoreWarnings, Resource::String::IgnoreWarningsArgumentDescription, ArgumentType::Flag, false };
Copy link
Member

Choose a reason for hiding this comment

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

Breaking or not, we should change --force per this discussion: #2112

@ghost ghost added the No-Recent-Activity Issue has no recent activity label Jun 14, 2022
@ghost
Copy link

ghost commented Jun 14, 2022

@ryfu-msft this pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 7 days of this comment.

@ghost ghost removed Needs-Author-Feedback Issue needs attention from issue or PR author No-Recent-Activity Issue has no recent activity labels Jun 16, 2022
@ryfu-msft ryfu-msft requested review from JohnMcPMS and yao-msft June 16, 2022 16:25
@ryfu-msft ryfu-msft deleted the displayWarning branch February 29, 2024 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Manifest This may require a change to the manifest Issue-Feature This is a feature request for the Windows Package Manager client.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[New Feature]: Add ability to display warning to user before upgrade
5 participants