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

License Validation outputs some errors and warnings when limit-output enabled. #2851

Open
corbob opened this issue Oct 6, 2022 · 1 comment · May be fixed by #2857
Open

License Validation outputs some errors and warnings when limit-output enabled. #2851

corbob opened this issue Oct 6, 2022 · 1 comment · May be fixed by #2857

Comments

@corbob
Copy link
Member

corbob commented Oct 6, 2022

What You Are Seeing?

When running a command with --limit-output, the License Validation will sometimes output errors and warnings.

What is Expected?

Chocolatey License Validation should not output unless absolutely necessary.

How Did You Get This To Happen? (Steps to Reproduce)

  1. Create a license directory in your Chocolatey install
  2. Add a file to the license directory (named something that is not chocolatey.license.xml
  3. Run choco list -lo --limit-output
  4. Observe the error and warning text about there not being a license, but about the license directory not being empty.

System Details

  • OS Build: Windows Server 2019
  • Windows PowerShell version: 5.1
  • Chocolatey version: 1.1.0

Output Log

N/A

@corbob
Copy link
Member Author

corbob commented Oct 6, 2022

Some context for anyone that might pick this up, I thought initially that this might be as simple as adding a check for regular output, but without debugging, it looks like a large portion of this is fixed by assessing the logic here:

private static bool determine_if_regular_output_for_logging()
{
var args = Environment.GetCommandLineArgs();
if (args == null || args.Length < 2) return true;
var firstArg = args[1].to_string();
if (firstArg.is_equal_to("-v") || firstArg.is_equal_to("--version")) return false;
return true;
}

corbob added a commit to corbob/choco that referenced this issue Oct 14, 2022
The LicenseValidation logging logic was only checking for `-v` or
`--version` as the first arguments. This completely ignored `-r`,
`--limit-output`, and `--limitoutput`. Additionally, a few places
weren't suppressing output when limit output was used. This change
correctly detects if regular output is desired, and if it is then it
marks the output accordingly, otherwise it outputs to the log file only.
@corbob corbob linked a pull request Oct 14, 2022 that will close this issue
9 tasks
@corbob corbob self-assigned this Oct 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant