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

Get-PSRule generates exception when no .rule.ps1 scripts exist in path #53

Closed
BernieWhite opened this issue Jan 10, 2019 · 0 comments
Closed
Assignees
Labels
bug Something isn't working
Milestone

Comments

@BernieWhite
Copy link
Member

Description of the issue

Get-PSRule does not gracefully handle the case where no .rule.ps1 files exist in the path and raises exceptions.

To Reproduce

Steps to reproduce the issue:

# With no .rule.ps1 files in current and child directories
Get-PSRule -Verbose;

Expected behaviour

Get-PSRule should return no results and no exceptions.

Error output

VERBOSE: [Get-PSRule]::BEGIN
VERBOSE: Attempting to read: .\psrule.yml
VERBOSE: [PSRule][D] -- Scanning for source files: C:\dev\Workspace\PSRule\dummy
The property 'Length' cannot be found on this object. Verify that the property exists.
At C:\Users\nnn\Documents\WindowsPowerShell\Modules\PSRule\0.2.0\PSRule.psm1:265 char:57
+ ... Verbose -Message "[Get-PSRule] -- Found $($sourceFiles.Length) script ...
+                                               ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], PropertyNotFoundException
    + FullyQualifiedErrorId : PropertyNotFoundStrict

VERBOSE: [Get-PSRule] -- Found  script(s)
Exception calling "Join" with "2" argument(s): "Value cannot be null.
Parameter name: values"
At C:\Users\nnn\Documents\WindowsPowerShell\Modules\PSRule\0.2.0\PSRule.psm1:266 char:64
+ ... [Get-PSRule] -- Found scripts: $([String]::Join(' ', $sourceFiles))";
+                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ArgumentNullException

Object reference not set to an instance of an object.
At C:\Users\nnn\Documents\WindowsPowerShell\Modules\PSRule\0.2.0\PSRule.psm1:286 char:13
+             $pipeline.Process();
+             ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], NullReferenceException
    + FullyQualifiedErrorId : System.NullReferenceException```

**Module in use and version:**

- Module: PSRule
- Version: 0.1.0 and 0.2.0-B190105
@BernieWhite BernieWhite added the bug Something isn't working label Jan 10, 2019
@BernieWhite BernieWhite added this to the v0.2.0 milestone Jan 10, 2019
BernieWhite added a commit that referenced this issue Jan 11, 2019
@BernieWhite BernieWhite self-assigned this Jan 11, 2019
BernieWhite added a commit that referenced this issue Jan 11, 2019
- Fix Get-PSRule generates exception when no .rule.ps1 scripts exist in path #53
- Fix LocalizedData.PathNotFound warning when no .rule.ps1 scripts exist in path #54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant