Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

[BUG] Get-PnPTerm throws misleading error if term not found #3037

Open
2 of 7 tasks
sympmarc opened this issue Jan 4, 2021 · 0 comments
Open
2 of 7 tasks

[BUG] Get-PnPTerm throws misleading error if term not found #3037

sympmarc opened this issue Jan 4, 2021 · 0 comments
Assignees
Labels

Comments

@sympmarc
Copy link
Contributor

sympmarc commented Jan 4, 2021

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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants