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

[BUG] Get-PnPSiteCollectionAppCatalog returns 'Object reference not set to an instance of an object' #2200

Closed
5 tasks
jessierobbins opened this issue Jul 27, 2022 · 2 comments · Fixed by #2201
Closed
5 tasks
Labels
bug Something isn't working

Comments

@jessierobbins
Copy link

Notice

Many bugs reported are actually related to the PnP Framework which is used behind the scenes. Consider carefully where to report an issue:

  1. Are you using Invoke-PnPSiteTemplate or Get-PnPSiteTemplate? The issue is most likely related to the Provisioning Engine. The Provisioning engine is not located in the PowerShell repo. Please report the issue here: https://github.com/pnp/pnpframework/issues.
  2. Is the issue related to the cmdlet itself, its parameters, the syntax, or do you suspect it is the code of the cmdlet that is causing the issue? Then please continue reporting the issue in this repo.
  3. If you think that the functionality might be related to the underlying libraries that the cmdlet is calling (We realize that might be difficult to determine), please first double check the code of the cmdlet, which can be found here: https://github.com/pnp/powershell/tree/master/src/Commands. If related to the cmdlet, continue reporting the issue here, otherwise report the issue at https://github.com/pnp/pnpframework/issues

Reporting an Issue or Missing Feature

Reporting an Issue

Expected behavior

The list of Site Collection app catalogs

Actual behavior

'Object reference not set to an instance of an object'
image

Steps to reproduce behavior

Connect-PnPOnline -url https://###-admin.sharepoint.com -Interactive
Get-PnPSiteCollectionAppCatalog

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

1.11.0 (Have confirmed this works as expected in 1.10.0)

Which operating system/environment are you running PnP PowerShell on?

  • [x ] Windows
  • Linux
  • MacOS
  • Azure Cloud Shell
  • Azure Functions
  • Other : please specify
@jessierobbins jessierobbins added the bug Something isn't working label Jul 27, 2022
@ryder-cayden
Copy link

ryder-cayden commented Jul 27, 2022

We are also running into the same issue.

It seems Line 69 of https://github.com/pnp/powershell/blob/dev/src/Commands/Admin/GetSiteCollectionAppCatalog.cs is causing this when the SiteID of a non-existing site collection is being passed. This happens when a site collection has been deleted and for some reason it does not get cleared up in the Site Collection App Catalog list(Lists/SiteCollectionAppCatalogs/AllItems.aspx) in the Tenant App Catalog:
appCatalogLocalModel.AbsoluteUrl = Tenant.GetSitePropertiesById(appCatalogLocalModel.SiteID.Value, false).Url; results.Add(appCatalogLocalModel);
I'm guessing there should be check if the Tenant.GetSitePropertiesById returns null:
`var tenantSite = Tenant.GetSitePropertiesById(appCatalogLocalModel.SiteID.Value, false);

if(tenantSite != null)
{
appCatalogLocalModel.AbsoluteUrl = tenantSite.Url;
results.Add(appCatalogLocalModel);
}
else
{
WriteVerbose($"Site collection App Catalog at {appCatalogLocalModel.AbsoluteUrl} does not exists");
}`

@milanholemans
Copy link
Contributor

We are also running into the same issue.

It seems Line 69 of https://github.com/pnp/powershell/blob/dev/src/Commands/Admin/GetSiteCollectionAppCatalog.cs is causing this when the SiteID of a non-existing site collection is being passed. This happens when a site collection has been deleted and for some reason it does not get cleared up in the Site Collection App Catalog list(Lists/SiteCollectionAppCatalogs/AllItems.aspx) in the Tenant App Catalog: appCatalogLocalModel.AbsoluteUrl = Tenant.GetSitePropertiesById(appCatalogLocalModel.SiteID.Value, false).Url; results.Add(appCatalogLocalModel); I'm guessing there should be check if the Tenant.GetSitePropertiesById returns null: `var tenantSite = Tenant.GetSitePropertiesById(appCatalogLocalModel.SiteID.Value, false);

if(tenantSite != null) { appCatalogLocalModel.AbsoluteUrl = tenantSite.Url; results.Add(appCatalogLocalModel); } else { WriteVerbose($"Site collection App Catalog at {appCatalogLocalModel.AbsoluteUrl} does not exists"); }`

This was indeed the case. Tenant.GetSitePropertiesById returns null for some deleted sites. I wrote a fix for this so it now takes this into account.

Thank you for the clarification @ryder-cayden!

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

Successfully merging a pull request may close this issue.

3 participants