prism icon indicating copy to clipboard operation
prism copied to clipboard

Error: Schema size exceeded

Open hainessss opened this issue 2 years ago • 3 comments

Hello,

I am getting Error: Schema size exceeded

And I can't figure out why.

repro script here

const { getHttpOperationsFromSpec } = require('@stoplight/prism-cli/dist/operations');
const { createClientFromOperations } = require('@stoplight/prism-http/dist/client');

(async function main () {
  let operations = await getHttpOperationsFromSpec('src/mocks/swagger.json');

  operations = operations.filter(operation => operation.path === '/api/candidate-role')

  console.log('operations', operations)
  const client = createClientFromOperations(operations, {
    mock: true,
  });

  client.get('/api/candidate-role').then(console.log);
})();

swagger schema here: https://prod.betterleap-api.com/api-docs-0001-json

Thanks

hainessss avatar Apr 07 '22 19:04 hainessss

@EdVinyard can you try to reproduce?

chohmann avatar Apr 15 '22 16:04 chohmann

I've reproduced this issue. We're bumping into a limit hard-coded into json-schema-sampler that limits the number of "nodes" in the response to 1000: https://github.com/stoplightio/json-schema-sampler/blob/master/src/traverse.js#L20

Switching Prism into dynamic mock mode gives me a different error, so I suggest we need to:

  1. (at least) return a much more descriptive error, and
  2. (probably) identify exactly what it is about this schema that breaks our mock generation.

EdVinyard avatar Apr 18 '22 16:04 EdVinyard

Hello,

I am working on generating mocks for openapi specifications for which sometimes have a very large response schema and I also get the error:

{
  "type": "https://stoplight.io/prism/errors#UNKNOWN",
  "title": "Schema size exceeded",
  "status": 500,
  "detail": ""
}

Are there any open working lines in order to modify by configuration these default values that are currently hardcoded? https://github.com/stoplightio/json-schema-sampler/blob/master/src/json-schema-sampler.js#L6

I urgently need a solution to this problem and will probably work on a fork as long as the configuration of these values is not enabled.

Thanks!

hernanpis-inditex avatar May 17 '22 09:05 hernanpis-inditex

Todo:

  • Improve error messaging
  • Create CLI parameter for expanding the node limit

ryotrellim avatar Mar 31 '23 16:03 ryotrellim

Hey team! Please add your planning poker estimate with Zenhub @chohmann @EdVinyard @daniel-white @brendarearden

ryotrellim avatar Mar 31 '23 19:03 ryotrellim

Caught the same behavior

dumndunm avatar Jul 07 '23 12:07 dumndunm

json schema sample is now doing

Schema size exceeded: over ${options.startingTicks} properties. For more info, visit https://docs.stoplight.io/docs/platform/zumkfdc16oypw-json-schema-editor#generate-examples

@ryotrellim is this a message we want for prism as well?

daniel-white avatar Jul 13 '23 17:07 daniel-white

@hainessss @leonovi @hernanpis-inditex

can you please provide us with a spec document that has this problem? thanks!

daniel-white avatar Jul 17 '23 15:07 daniel-white

This triggers it for me

https://docs.medusajs.com/api/store -> spec

docker-compose.yml

services:
  mock_store:
    # https://docs.medusajs.com/api/store
    image: stoplight/prism:4
    command: >
      mock -p 4010 --host 0.0.0.0
      https://docs.medusajs.com/redocusaurus/plugin-redoc-0.yaml
/store/carts/1
{
	"type": "https://stoplight.io/prism/errors#UNKNOWN",
	"title": "Schema size exceeded",
	"status": 500,
	"detail": ""
}

tyler71 avatar Jul 19 '23 06:07 tyler71

saving spec for future plugin-redoc-0.yaml.txt

daniel-white avatar Jul 19 '23 14:07 daniel-white

Unfortunately, i won't be able to provide a schema ☹️. But perhaps i will be able to make a scheme manually, with the same level of nesting and the count of nodes, if there is time.

dumndunm avatar Jul 22 '23 12:07 dumndunm

Attempt to fix Prism build problem due to Stoplight's fork of HTTPbin used during the build: https://github.com/stoplightio/httpbin/pull/4

EdVinyard avatar Jul 25 '23 17:07 EdVinyard