winget-cli icon indicating copy to clipboard operation
winget-cli copied to clipboard

Fix for Source Argument Validation in SourceWorkflow for Default Source Type

Open Madhusudhan-MSFT opened this issue 1 year ago • 1 comments

Fix for Source Argument Validation in SourceWorkflow for Default Source Type

[Issues:] The current validation in the source flow correctly detects duplicate source names. However, when the source argument is validated along with the source type, it allows different source names with the same arguments for the empty source type. This happens because, during source type comparison, if the source type is not provided, it defaults to an empty string, which is compared against the default type (Microsoft.PreIndexed). This allows multiple different source names with the same argument to be considered valid sources. For an empty source type, the default source type is assigned during the source add operation, not beforehand. Consequently, after the source add operation is finished, the source will have some source arguments, but only the name will differ.

[Fix:]

For an empty source type, we should compare against the default source to prevent different source names with the same arguments for the default types. During validation, we obtain the default type to replace the empty source type and use it for comparison to validate argument duplication.

  • Extended source tests to validate the duplicate source argument scenario for the default source type.
  • Fixed additional failing source origin tests with appropriate fixes.

[How Validated:]

  • Compiled the latest modifications and deployed the AppInstallerCLIPackage.
  • Executed CLI SourceTests to ensure all tests pass without issues.

Microsoft Reviewers: Open in CodeFlow

Madhusudhan-MSFT avatar Oct 19 '24 07:10 Madhusudhan-MSFT

@check-spelling-bot Report

:red_circle: Please review

See the :open_file_folder: files view, the :scroll:action log, or :memo: job summary for details.

Unrecognized words (1)

testsource

Previously acknowledged words that are now absent AKV Asn azcopy clsid cobertura notmatch Peet REINSTALLMODE sas SASURL similarissues similaritytolerance templating typeparam 🫥
Some files were automatically ignored :see_no_evil:

These sample patterns would exclude them:

^src/AppInstallerCLIE2ETests/TestData/empty$

You should consider adding them to:

.github/actions/spelling/excludes.txt

File matching is via Perl regular expressions.

To check these files, more of their words need to be in the dictionary than not. You can use patterns.txt to exclude portions, add items to the dictionary (e.g. by adding them to allow.txt), or fix typos.

To accept these unrecognized words as correct and remove the previously acknowledged and now absent words and update file exclusions, you could run the following commands

... in a clone of the [email protected]:Madhusudhan-MSFT/winget-cli.git repository on the user/masudars/SourceCLI_DefaultSourceType_ValidationFix branch (:information_source: how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.22/apply.pl' |
perl - 'https://github.com/microsoft/winget-cli/actions/runs/11415559540/attempts/1'
Warnings (1)

See the :open_file_folder: files view, the :scroll:action log, or :memo: job summary for details.

:information_source: Warnings Count
:information_source: binary-file 1

See :information_source: Event descriptions for more information.

If the flagged items are :exploding_head: 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.

github-actions[bot] avatar Oct 19 '24 07:10 github-actions[bot]