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-ChangelogData: Throws an exception if Unreleased header is misspelled #26

Open
johlju opened this issue Dec 10, 2022 · 2 comments
Open
Labels
bug Something isn't working

Comments

@johlju
Copy link
Contributor

johlju commented Dec 10, 2022

This line throws an error if the Unreleased is misspelled.

"Date" = Get-Date ($Release -split "\] \- ")[1].Split($FileNewline)[0]

Having the change log like:

## [Unrelesed]

## [0.12.0] - 2022-12-10

### Added

- Something added

Calling this:

Get-ChangelogData -Path .\CHANGELOG.md

throws this:

Exception             :
    Type        : System.Management.Automation.RuntimeException
    ErrorRecord :
        Exception             :
            Type    : System.Management.Automation.ParentContainsErrorRecordException
            Message : You cannot call a method on a null-valued expression.
            HResult : -2146233087
        CategoryInfo          : InvalidOperation: (:) [], ParentContainsErrorRecordException
        FullyQualifiedErrorId : InvokeMethodOnNull
        InvocationInfo        :
            ScriptLineNumber : 113
            OffsetInLine     : 25
            HistoryId        : -1
            ScriptName       : C:\source\DscResource.Common\output\RequiredModules\ChangelogManagement\3.0.0\public\Get-ChangelogData.ps1
            Line             :             "Date"    = Get-Date ($Release -split "\] \- ")[1].Split($FileNewline)[0]

            PositionMessage  : At C:\source\DscResource.Common\output\RequiredModules\ChangelogManagement\3.0.0\public\Get-ChangelogData.ps1:113 char:25
                               + … "Date"    = Get-Date ($Release -split "\] \- ")[1].Split($FileNewline …
                               +               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            PSScriptRoot     : C:\source\DscResource.Common\output\RequiredModules\ChangelogManagement\3.0.0\public
            PSCommandPath    : C:\source\DscResource.Common\output\RequiredModules\ChangelogManagement\3.0.0\public\Get-ChangelogData.ps1
            CommandOrigin    : Internal
        ScriptStackTrace      : at Get-ChangelogData, C:\source\DscResource.Common\output\RequiredModules\ChangelogManagement\3.0.0\public\Get-ChangelogData.ps1: line 113
                                at <ScriptBlock>, <No file>: line 1
    TargetSite  : System.Object CallSite.Target(System.Runtime.CompilerServices.Closure, System.Runtime.CompilerServices.CallSite, System.Object, System.Object)
    Message     : You cannot call a method on a null-valued expression.
    Source      : Anonymously Hosted DynamicMethods Assembly
    HResult     : -2146233087
    StackTrace  :
   at CallSite.Target(Closure, CallSite, Object, Object)
   at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
   at lambda_method2941(Closure, Object[], StrongBox`1[], InterpretedFrame)
CategoryInfo          : InvalidOperation: (:) [], RuntimeException
FullyQualifiedErrorId : InvokeMethodOnNull
InvocationInfo        :
    ScriptLineNumber : 113
    OffsetInLine     : 25
    HistoryId        : -1
    ScriptName       : C:\source\DscResource.Common\output\RequiredModules\ChangelogManagement\3.0.0\public\Get-ChangelogData.ps1
    Line             :             "Date"    = Get-Date ($Release -split "\] \- ")[1].Split($FileNewline)[0]

    PositionMessage  : At C:\source\DscResource.Common\output\RequiredModules\ChangelogManagement\3.0.0\public\Get-ChangelogData.ps1:113 char:25
                       + … "Date"    = Get-Date ($Release -split "\] \- ")[1].Split($FileNewline …
                       +               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    PSScriptRoot     : C:\source\DscResource.Common\output\RequiredModules\ChangelogManagement\3.0.0\public
    PSCommandPath    : C:\source\DscResource.Common\output\RequiredModules\ChangelogManagement\3.0.0\public\Get-ChangelogData.ps1
    CommandOrigin    : Internal
ScriptStackTrace      : at Get-ChangelogData, C:\source\DscResource.Common\output\RequiredModules\ChangelogManagement\3.0.0\public\Get-ChangelogData.ps1: line 113
                        at <ScriptBlock>, <No file>: line 1
@johlju johlju changed the title Get-ChangelogData: Throws an exception if Unreleased header is misspelled. Get-ChangelogData: Throws an exception if Unreleased header is misspelled Dec 10, 2022
@natescherer
Copy link
Owner

Having some level of document structure validation is probably a good idea rather than just assuming the doc matches KaC 1.0.0. I'll throw the general concept of document validation for Update-Changelog and Get-ChangelogData onto the todo pile.

@natescherer natescherer added the enhancement New feature or request label Dec 23, 2022
@johlju
Copy link
Contributor Author

johlju commented Dec 24, 2022

Yeah, I think it just need to throw a better error message saying that header X does not conform to the expected format.

@natescherer natescherer added bug Something isn't working and removed enhancement New feature or request labels Dec 27, 2022
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

2 participants