SCRT-HQ / PSGSuite

Powershell module for Google / G Suite API calls wrapped in handy functions. Authentication is established using a service account via P12 key to negate the consent popup and allow for greater handsoff automation capabilities
https://psgsuite.io/
Apache License 2.0
235 stars 67 forks source link

Sync-GSUserCache error #298

Closed IronKane2 closed 4 years ago

IronKane2 commented 4 years ago

I've been running this script hourly for over a year with no issues. Is there an upper limit to the GSUserCache?

Executing this: $GSUsers = Sync-GSUserCache -PassThru -verbose

Produces this: VERBOSE: Syncing users to $global:GSUserCache VERBOSE: Building ServiceAccountCredential from P12Key as user 'srcampbell@djusd.net' VERBOSE: Getting all Users for customer '########' VERBOSE: Retrieved 500 users... blah blah blah VERBOSE: Retrieved 17000 users...

Get-GSUser : Exception calling "Execute" with "0" argument(s): "Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'System.Collections.Generic.IDictionary2[System.String,System.Collections.Generic.IDictionary2[System.String,System.Object]]' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly. To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array. Path 'users[435].customSchemas', line 19076, position 24." At C:\Program Files\WindowsPowerShell\Modules\PSGSuite\2.35.1\PSGSuite.psm1:29469 char:9

scrthq commented 4 years ago

Hey @IronKane2 - There shouldn't be an upper limit; all the UserCache is is a local variable containing an array. That being said, we saw similar issues with the Admin SDK failing to deserialize the customSchemas value as well a few days ago; it appeared that Google was returning an array instead of a dictionary for the customSchemas value, resulting in the .NET SDK failing to deserialize to the expected value. I'm assuming you're also no longer seeing this error?

IronKane2 commented 4 years ago

HI Nate,

I think it was Google that was having the issue. Later on it started working and I haven’t seen a repeat. I updated my script and wrapped my code with an If count > 0 so it wouldn’t proceed if my hash table was empty. Thanks for your response. You can close the ticket.

-Steve

From: Nate Ferrell notifications@github.com Sent: Saturday, June 27, 2020 1:36 PM To: SCRT-HQ/PSGSuite PSGSuite@noreply.github.com Cc: Steve Campbell srcampbell@djusd.net; Mention mention@noreply.github.com Subject: Re: [SCRT-HQ/PSGSuite] Sync-GSUserCache error (#298)

Hey @IronKane2https://nam05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FIronKane2&data=01%7C01%7Csrcampbell%40djusd.net%7C5eda840acda645f7d21508d81ad9bfe2%7Cffeaaba7f17b4005868826a67d89300a%7C1&sdata=UfrDiCDq91weojZOhmmiZQxY9qyAJNBfxTpF%2B1oy1zE%3D&reserved=0 - There shouldn't be an upper limit; all the UserCache is is a local variable containing an array. That being said, we saw similar issues with the Admin SDK failing to deserialize the customSchemas value as well a few days ago; it appeared that Google was returning an array instead of a dictionary for the customSchemas value, resulting in the .NET SDK failing to deserialize to the expected value. I'm assuming you're also no longer seeing this error?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FSCRT-HQ%2FPSGSuite%2Fissues%2F298%23issuecomment-650621482&data=01%7C01%7Csrcampbell%40djusd.net%7C5eda840acda645f7d21508d81ad9bfe2%7Cffeaaba7f17b4005868826a67d89300a%7C1&sdata=y3Uq%2FiGxQpp8sOV1W1lwRW5u5mRPdixXhxNMB20QShs%3D&reserved=0, or unsubscribehttps://nam05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAKCMAFXU6D2Y3J3JOQN3533RYZJ4HANCNFSM4OGEY5RQ&data=01%7C01%7Csrcampbell%40djusd.net%7C5eda840acda645f7d21508d81ad9bfe2%7Cffeaaba7f17b4005868826a67d89300a%7C1&sdata=WTdeKqv9qov3CoWIMOXNs%2B0h6nrl5mo4MP3l3dkjFsE%3D&reserved=0.