Import fails for resource-servers containing too many (over 20) scopes.
See original GitHub issueDescription
Import fails for resource-servers containing too many scopes.
Reproduction
We have API definition similar to this
`
{
"name": "SomeAPI",
"identifier": "https://someapi.io",
"signing_alg": "RS256",
"skip_consent_for_verifiable_first_party_clients": true,
"enforce_policies": true,
"scopes": [
{
"value": "read:keys",
"description": "Read or get an encryption key"
},
.... 20 more scopes
{
"value": "read:data",
"description": "Read data"
}
]
}
`
(the scopes are of course correct). When importing, we end up with error Payload validation error: 'Expected type object but found type string' on property scopes[21]. (also) Payload validation error: 'Expected type object but found type string' on property scopes[20].
(this is deployment setup that used to work for years, but now suddenly fails. It also works fine when calling the management API directly, through curl or the API web).
I’ve debugged the code locally and I think I found the culprit, though I am not sure who is the guilty party here (CLI, auth0 package, or their dependencies). Basically, the CLI uses the auth0 library’s rest client, which in turns uses superagent, and that internally uses fast-safe-stringify package to serialize the json data. This is called with default options, which include edgesLimit set to 20, and thus the json is serialized like this "{\"name\":\"SomeAPI\",\"signing_alg\":\"RS256\",\"skip_consent_for_verifiable_first_party_clients\":true,\"enforce_policies\":true,\"scopes\":[{\"value\":\"read:keys\",\"description\":\"Read or get an encryption key\"},......{\"value\":\"lastWorkingScope\",\"description\":\"LastWorkingScope\"},\"[...]\",\"[...]\"]}"
(i.e. the last 2 entries get replaced with "[...]")
Environment
auth0-deploy-cli@7.2.1 auth0@2.36.1 superagent@5.3.1 fast-safe-stringify@2.1.0
Node version 12.18.2 running on windows (local test) or linux (CI)
Issue Analytics
- State:
- Created 2 years ago
- Comments:5

Top Related StackOverflow Question
This: https://github.com/davidmarkclements/fast-safe-stringify/issues/57 seems to be the problem, hopefully a new release will come soon, till then, simply revert back to
fast-safe-stringify@2.0.8locally, a bit of hack, but it works.I guess no special action in this repo is needed, so I am closing this. Thanks!