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

Get-AzADUser -Search fails on pagination #17667

Closed
Agazoth opened this issue Mar 29, 2022 · 3 comments · Fixed by #17705 or #17849
Closed

Get-AzADUser -Search fails on pagination #17667

Agazoth opened this issue Mar 29, 2022 · 3 comments · Fixed by #17705 or #17849
Assignees
Labels
AAD AzAd cmdlets in Az.Resources bug This issue requires a change to an existing behavior in the product in order to be resolved. customer-reported

Comments

@Agazoth
Copy link
Contributor

Agazoth commented Mar 29, 2022

Description

If a Search returns paginated results, FollowingNextLink gets corrupted

We have more then 100 users with "konsulent" in the job title. When quering these, the first barch is returned, but the the query fails on the nextLink run.

$k = Get-AzADUser -Search "JobTitle:Konsulent" -ConsistencyLevel eventual # a group of users larger then 100

Expected result is a list of more then 100 users

Actual result is an error

From the debug result it is clear, that the nextLink uri is wrong: https://graph.microsoft.com/v1.0/users?$search=""JobTitle%3aKonsulent""&$skiptoken=m~AQAnOzU4NTg0MGQzOTJkZDRiNTc5YmUxMzZlYzJiMjZmMTVjOzswOzA7

If I remove the double quotation and query this uri: https://graph.microsoft.com/v1.0/users?$search="JobTitle%3aKonsulent"&$skiptoken=m~AQAnOzU4NTg0MGQzOTJkZDRiNTc5YmUxMzZlYzJiMjZmMTVjOzswOzA7 I get the next batch of users.

Issue script & Debug output

DEBUG: [CmdletBeginProcessing]: Starting command
DEBUG: CmdletBeginProcessing:
DEBUG: CmdletProcessRecordStart:
DEBUG: Client side pagination is enabled for this cmdlet
DEBUG: [CmdletProcessRecordAsyncStart]: Created new QosEvent for command 'Get-AzADUser_List'
DEBUG: CmdletProcessRecordAsyncStart:
DEBUG: CmdletGetPipeline:
DEBUG: CmdletBeforeAPICall:
DEBUG: URLCreated: /users?$search=JobTitle%3AKonsulent
DEBUG: RequestCreated: /v1.0/users?$search=JobTitle%3AKonsulent
DEBUG: HeaderParametersAdded:
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://graph.microsoft.com/v1.0/users?$search="JobTitle%3AKonsulent"

Headers:
ConsistencyLevel              : eventual
x-ms-unique-id                : 199
x-ms-client-request-id        : 2c9d715c-2a74-48b7-aa9a-f9c8279861f0
CommandName                   : Az.MSGraph.internal\Get-AzADUser
FullCommandName               : Get-AzADUser_List
ParameterSetName              : __AllParameterSets
User-Agent                    : AzurePowershell/v7.3.2,PSVersion/v7.2.2,Az.MSGraph/5.4.0

Body:

(First batch of 100 returned here)

DEBUG: ResponseCreated:
DEBUG: BeforeResponseDispatch:
DEBUG: FollowingNextLink:
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://graph.microsoft.com/v1.0/users?$search=""JobTitle%3aKonsulent""&$skiptoken=m~AQAnOzU4NTg0MGQzOTJkZDRiNTc5YmUxMzZlYzJiMjZmMTVjOzswOzA7

Headers:
ConsistencyLevel              : eventual
x-ms-unique-id                : 200
x-ms-client-request-id        : 2c9d715c-2a74-48b7-aa9a-f9c8279861f0
CommandName                   : Az.MSGraph.internal\Get-AzADUser
FullCommandName               : Get-AzADUser_List
ParameterSetName              : __AllParameterSets
User-Agent                    : AzurePowershell/v7.3.2,PSVersion/v7.2.2,Az.MSGraph/5.4.0

Body:

Environment data

Name                           Value
----                           -----
PSVersion                      7.2.2
PSEdition                      Core
GitCommitId                    7.2.2
OS                             Microsoft Windows 10.0.22000
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

PS> Get-Module Az*

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     2.7.4                 Az.Accounts                         {Add-AzEnvironment, Clear-AzContext, Clear-AzDefa…
Script     5.4.0                 Az.Resources                        {Export-AzResourceGroup, Export-AzTemplateSpec, G…

Error output

Message        : [BadRequest] : An identifier was expected at position 0.
StackTrace     :
Exception      : System.Exception
InvocationInfo : {Get-AzADUser_List}
Line           :         Az.MSGraph.internal\Get-AzADUser @PSBoundParameters

Position       : At C:\Users\Ax\Documents\PowerShell\Modules\Az.Resources\5.4.0\MSGraph.Autorest\custom\Get-AzADUser.ps
                 1:210 char:9
                 +         Az.MSGraph.internal\Get-AzADUser @PSBoundParameters
                 +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 2
@Agazoth Agazoth added bug This issue requires a change to an existing behavior in the product in order to be resolved. needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Mar 29, 2022
@ghost ghost added customer-reported and removed needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Mar 29, 2022
@dingmeng-xue dingmeng-xue added AAD AzAd cmdlets in Az.Resources good first issue Issues suited for folks who want to help for the first time. labels Mar 29, 2022
@dingmeng-xue
Copy link
Member

Yes, I can reproduce that problem. @VeryEarly , please check which layer has the problem.

@dingmeng-xue dingmeng-xue removed the good first issue Issues suited for folks who want to help for the first time. label Mar 30, 2022
@VeryEarly VeryEarly self-assigned this Mar 30, 2022
@Agazoth
Copy link
Contributor Author

Agazoth commented Mar 30, 2022

The exact same error exists for Get-AzADGroup. I assume it uses the same layer.

@VeryEarly
Copy link
Contributor

Hi @Agazoth ,

Thanks for contributing the neat fix, however to make this change roll out next release, our process is to update generation branch first. I have made new PR #17705 , and will list your contribution in next release anyway.

Thanks

@VeryEarly VeryEarly linked a pull request Apr 2, 2022 that will close this issue
8 tasks
@VeryEarly VeryEarly linked a pull request Apr 19, 2022 that will close this issue
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AAD AzAd cmdlets in Az.Resources bug This issue requires a change to an existing behavior in the product in order to be resolved. customer-reported
Projects
None yet
3 participants