deepObject passes validation when it's an array
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 55/100
Research direction
The bug is in OpenapiParameters::Query#parse_deep_object, where prop_regx fails to match keys like filters and filters[], so the property key becomes nil. Start by reproducing the schema from the issue as a request spec and confirming that filters=foo and filters[]=1&filters[]=2 both pass. Done means both requests fail validation against the object-typed filters parameter, with existing deepObject specs still passing.
Written by the indexing model from the issue text.
Description
I am not sure whether that's on purpose or whether that's a bug, but I've just spotted a (imo) surprising behaviour during deep object validation. Given schema definition like this:
paths:
/foo:
get:
parameters:
- name: filters
in: query
required: false
style: deepObject
explode: true
schema:
type: object
properties:
first:
type: array
items:
type: string
second:
type: array
items:
type: string
When making a request with following params:
filters=foofilters[]=1&filters[]=2
the validation passed.
This surprised me because I'd expect it to fail as neither string nor array should be allowed, should they? Since in rails app you can then access the params[:filters] and it's a string or an array (respectively) it creates a risky precedence.
It's caused by the OpenapiParameters::Query#parse_deep_object where prop_key = key.match(prop_regx)&.[](1) returns nil because the regex won't match keys like filters nor filters[].
- Dominant language
- Ruby
- Stars
- 222
- Forks
- 27
- Avg merge
- 17h 15m
- Merged PRs (30d)
- 6
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ahx/openapi_first
-
Multipart file uploads fail validation with ActionDispatch::Request (UploadedFile isn't a Hash)Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ahx/openapi_first#516 · 1 comment ·
-
OpenAPI 3.2 supportMay be free again A pull request for this issue was closed without being merged. Openenhancement
Difficulty 4/5 3-5 days Newbie friendliness 22/100
ahx/openapi_first#469 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
ahx/openapi_first#458 · 4 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 12/100
ahx/openapi_first#425 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
ahx/openapi_first#418 · 1 comment · 1 reaction ·
All issues in ahx/openapi_first
Similar issues
-
Bug Ruby
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
getsentry/sentry-ruby#3211 · 1 comment ·
Maintainers usually reply within 2 days
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
internetee/registry#2984 ·
Maintainers usually reply within 6 days
-
interest-zsv
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
hitobito/hitobito_zsv#6 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
ecosyste-ms/issues#862 ·
Maintainers usually reply within 1 day
-
Redis Lua error `@user_script:52: ERR value is not an integer or out of range` when `window_size` is configuredPossibly taken @mimosa claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day