Disable some limits when JSON parsing OpenAPI data

What does this MR do and why?

This MR disables two limits when JSON parsing OpenAPI data in our rake tasks.

  • max_total_elements
  • max_json_size_bytes

Currently we're tripping the max_total_elements limit when we generate or check our Open API YAML data.

This MR also disables the max_json_size_bytes limit as that seems likely to be tripped in future too.

How to set up and validate locally

On master, run either of these commands:

bundle exec rake gitlab:openapi:v2:generate
bundle exec rake gitlab:openapi:v2:check_docs

You'll see the error:

Generating OpenAPI v2 docs with GITLAB_SIMULATE_SAAS=false (override with OPENAPI_SIMULATE_SAAS=true)
rake aborted!
JSON::ParserError: Too many total parameters (JSON::ParserError)
/Users/luke/Sites/gdk/gitlab/lib/gitlab/json/safe_parser.rb:169:in `raise_human_readable_error!'
/Users/luke/Sites/gdk/gitlab/lib/gitlab/json/safe_parser.rb:136:in `rescue in parse'
/Users/luke/Sites/gdk/gitlab/lib/gitlab/json/safe_parser.rb:130:in `parse'
/Users/luke/Sites/gdk/gitlab/lib/gitlab/json/safe_parser.rb:96:in `parse'
/Users/luke/Sites/gdk/gitlab/lib/tasks/gitlab/openapi/v2.rake:45:in `block (4 levels) in <main>'

Caused by:
Oj::Parser::TotalElementsError: Too many elements! (Oj::Parser::TotalElementsError)
/Users/luke/Sites/gdk/gitlab/lib/gitlab/json/safe_parser.rb:134:in `parse'
/Users/luke/Sites/gdk/gitlab/lib/gitlab/json/safe_parser.rb:134:in `parse'
/Users/luke/Sites/gdk/gitlab/lib/gitlab/json/safe_parser.rb:96:in `parse'
/Users/luke/Sites/gdk/gitlab/lib/tasks/gitlab/openapi/v2.rake:45:in `block (4 levels) in <main>'

Run the commands on this branch and the YAML files should compile / be checked successfully.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Luke Duncalfe

Merge request reports

Loading
Loading