pnp / pnp/powershell

Get-PnPHubSite doesn't return NULL then the specified URL or Id points to a site that is not a hub site

Open
#5,032 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C#
Stars
904
Forks
407
Avg merge
9h 16m
Merged PRs (30d)
10

Description

Actual behavior

Get-PnPHubSite currently returns a not-null respons when calling using a valid URL to a site that is not a hub site. I would expect a null value

Steps to reproduce behavior

part of an Azure Function:
$SPOAdminUrl = "the URL of the SP admin site"
$siteUrl = "contoso.sharepoint.com/sites/nothubsite"
$adminConn = Connect-PnPOnline -Url $SPOAdminUrl -Interactive -ClientId $PnPClientId -ReturnConnection
$hubSite = Get-PnPHubSite -Identity $siteUrl -Connection $adminConn -ErrorAction Stop
if($hubSite) #this fails as $hubSite is not null
{
$body += "The site $siteUrl is already registered as a hub site"
$StatusCode = [HttpStatusCode]::AlreadyReported
}

What is the version of the Cmdlet module you are running?

3.1.0

Which operating system/environment are you running PnP PowerShell on?
  • Windows
  • Linux
  • MacOS
  • Azure Cloud Shell
  • Azure Functions
  • Other : please specify

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Get-PnPHubSite cmdlet entry point and reproduce the reported call with a valid URL or Id for a site that is not a hub site. Verify the behavior for both non-hub and hub sites, and consider the issue complete when the former returns null while the latter still returns its hub-site result.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.