[BUG] Get-PnPTerm throws misleading error if term not found
sympmarc opened this issue · comments
Reporting an Issue or Missing Feature
When I call Get-PnPTerm with a value which is not in the Term Set like so:
Get-PnPTerm -TermGroup $termGroup -TermSet $termSet -Identity $splitValues[$i] -Recursive
I get the following error:
Get-PnPTerm : Value cannot be null.
Parameter name: clientObject
At line:1 char:1
+ Get-PnPTerm -TermGroup $termGroup -TermSet $termSet -Identity $splitV ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [Get-PnPTerm], ArgumentNullException
+ FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.Taxonomy.GetTerm
This is misleading, as the values I'm passing in are not null. @ToddKlindt and I looked at them carefully. (Trust, but verify!)
Expected behavior
I expect to get a null term back, but not an error.
Actual behavior
See error above.
I expect the issue is in parsing the response from core. When I remove -Recursive
the error is a little different:
Get-PnPTerm : Specified argument was out of the range of valid values.
Parameter name: index
At line:1 char:1
+ Get-PnPTerm -TermGroup $termGroup -TermSet $termSet -Identity $splitV ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (:) [Get-PnPTerm], ServerException
+ FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.Taxonomy.GetTerm
If I use -ErrorAction SilentlyContinue
I can supress the error, but I don't think I should need to.
Steps to reproduce behavior
Call Get-PnPTerm
with any TermSet
using an -Identity
which is not present.
Which version of the PnP-PowerShell Cmdlets are you using?
- PnP PowerShell for SharePoint 2013
- PnP PowerShell for SharePoint 2016
- PnP PowerShell for SharePoint 2019
- PnP PowerShell for SharePoint Online
What is the version of the Cmdlet module you are running?
3.28.2012
How did you install the PnP-PowerShell Cmdlets?
- MSI Installed downloaded from GitHub
- Installed through the PowerShell Gallery with Install-Module
- Other means