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

GetSiteSearchQueryResults: fix 'Value cannot be null' exception #2138

Merged
merged 4 commits into from
Jul 13, 2022

Conversation

fowl2
Copy link
Contributor

@fowl2 fowl2 commented Jul 13, 2022

Type

  • Bug Fix

Related Issues?

Fixes #2130

Repro

  1. Connect to a site using Connect-PnPOnline
  2. Run Get-PnPSiteSearchQueryResults

This exception occurs:

Message          : Value cannot be null.
                   Parameter name: context
Stacktrace       :    at Microsoft.SharePoint.Client.ObjectPath..ctor(ClientRuntimeContext context, ObjectPath 
                   parent, Boolean addToContext)
                      at Microsoft.SharePoint.Client.ObjectPathConstructor..ctor(ClientRuntimeContext context, 
                   String typeId, Object[] parameters)
                      at Microsoft.SharePoint.Client.Search.Query.KeywordQuery..ctor(ClientRuntimeContext 
                   context)
                      at PnP.PowerShell.Commands.Search.SubmitSearchQuery.CreateKeywordQuery(String 
                   clientFunction)
                      at PnP.PowerShell.Commands.Search.SubmitSearchQuery.Run()
                      at PnP.PowerShell.Commands.Search.GetSiteSearchQueryResults.ExecuteCmdlet()
                      at PnP.PowerShell.Commands.PnPSharePointCmdlet.ProcessRecord()

I'm honestly not sure how this cmdlet ever worked without passing the connection. I've had a quick look through the commit history and see nothing obvious.

What is in this Pull Request ?

Pass the connection from the parent cmdlet to the child cmdlet, so that it can access the ClientContext.

@KoenZomers
Copy link
Collaborator

Thanks @fowl2 !

@KoenZomers KoenZomers merged commit 707db2c into pnp:dev Jul 13, 2022
@fowl2 fowl2 deleted the fixGetSiteSearchQueryResults branch July 13, 2022 08:28
@IfEyeOnlyKnew
Copy link

IfEyeOnlyKnew commented Jul 18, 2022

Just checking, but would this change show up in the latest version?

Running from Visual Studio Code, powershell 7, connecting to SharePoint Online Tenant Admin, https://tenant-admin.sharepoint.com, but when I run Get-PnPSiteSearchQueryResults -MaxResults 3, it is returning Site Collection results from the On-Premises SharePoint server I am running this command from.

@KoenZomers
Copy link
Collaborator

It should be in the latest nightly build indeed. It showing on prem results can only be reasoned based on the information provided that you're having a cloud search service application enabled on your on prem farm which is sending its index to spo. If that's the case, then this is expected behavior.

@thaiphv
Copy link

thaiphv commented Aug 11, 2022

Can this be released as a new release? My company's Proget feed only clones non-nightly releases.

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.

4 participants