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

Fix ConvertFrom-ExistingSubmission exception when no Advanced Listings support #110

Merged
merged 1 commit into from
Feb 15, 2018

Conversation

HowardWolosky
Copy link
Member

While this scenario had been tested brefore, clearly something had been missed.
It appears that if you pass $null (the result of $Submission.trailerswhen the application doesn't have Advanced Listing support) toForEach-Object, that iterates once (for the $null) which will eventually result into a call of $null | Get-Member -Type NotePropertywhich throws an exception since you haven't passed an object toGet-Member`.

The fix is to simply switch to a standard foreach as opposed to the ForEach-Object
cmdlet.

…o trailers

While this scenario had been tested brefore, clearly something had been missed.
It appears that if you pass `$null` (the result of $Submission.trailers` when
the application doesn't have Advanced Listing support) to `ForEach-Object`,
that iterates once (for the `$null`) which will eventually result into a call of
`$null | Get-Member -Type NoteProperty` which throws an exception since you haven't
passed an object to `Get-Member`.

The fix is to simply switch to a standard `foreach` as opposed to the `ForEach-Object`
cmdlet.
@@ -933,72 +933,72 @@ function Add-Trailers
Add-ToElement @paramSet

$trailerCount = 0
$Submission.trailers |
ForEach-Object {
Copy link
Contributor

Choose a reason for hiding this comment

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

Alternatively, could have added a Where-Object { $null -ne $_ } |

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, could have, but I feel like that would just add more questions as to "why would that happen?" as opposed to just using foreach where the behavior feels more clearly understood for anyone coming in to look at the code.

@HowardWolosky HowardWolosky merged commit e9b8b2b into microsoft:master Feb 15, 2018
@HowardWolosky HowardWolosky deleted the convertFix branch February 15, 2018 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants