Skip to content

Import fails for resource-servers containing too many (over 20) scopes. #376

@Wintermoose

Description

@Wintermoose

Description

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions