Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OPEN API web validation with query parameter using string Enum fails with exception #1875

Closed
pantinor opened this issue Feb 24, 2021 · 7 comments
Assignees
Milestone

Comments

@pantinor
Copy link

Questions

Do not use this issue tracker to ask questions, instead use one of these channels. Questions will likely be closed without notice.

Version

4.0.2

Context

Observing a web validation parameter YAML parsing issue when using an ENUM with a query param like below.
Web validation fails on the request.
Debugging down into it seems to stop at the validator.getDefault line 43 ParameterProcessorImpl.
I tried removing the Reference and putting the enum inline into the parameter with a default value, but still the same 500 error is thrown.

Expectation is that a string enum may be used with a open api based query parameter without encountering a 500 rejection or NoSyncValidationException.

  • name: match1
    in: query
    required: false
    schema:
    $ref: '#/components/schemas/MatchingAlgorithm'

MatchingAlgorithm:
type: string
enum:
- BEST
- EXACT
- STARTS_WITH

throw new NoSyncValidationException("Trying to execute validateSync() for a Validator in asynchronous state", this);

Do you have a reproducer?

If we think there is a bug to fix and it is not user error, I can make a reproducer. Currently can only reproduce in in house tests.

Steps to reproduce

  1. Add a enum to a string query paramater in a yaml operation such as GET.
  2. Start http server / verticle with Router that loads the YAML operation.
  3. Send a request for processing and encounter 500 code on the response.
  4. Debugging into the stack like below seeing logic get into checkSync and validator.getDefault function of ParameterProcessorImpl where exception is thrown.

Extra

at io.vertx.ext.web.validation.impl.parameter.ParameterProcessorImpl.process(ParameterProcessorImpl.java:43)
at io.vertx.ext.web.validation.impl.ValidationHandlerImpl.processParams(ValidationHandlerImpl.java:258)
at io.vertx.ext.web.validation.impl.ValidationHandlerImpl.validateQueryParams(ValidationHandlerImpl.java:227)
at io.vertx.ext.web.validation.impl.ValidationHandlerImpl.handle(ValidationHandlerImpl.java:109)
at io.vertx.ext.web.validation.impl.ValidationHandlerImpl.handle(ValidationHandlerImpl.java:18)
at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1107)
at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:114)
at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:133)
at io.vertx.ext.web.handler.impl.ResponseContentTypeHandlerImpl.handle(ResponseContentTypeHandlerImpl.java:54)
at io.vertx.ext.web.handler.impl.ResponseContentTypeHandlerImpl.handle(ResponseContentTypeHandlerImpl.java:28)
at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1107)
at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:114)
at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:133)
at io.vertx.ext.web.openapi.impl.OpenAPI3RouterBuilderImpl.lambda$createRouter$12(OpenAPI3RouterBuilderImpl.java:314)
at io.vertx.ext.web.openapi.impl.OpenAPI3RouterBuilderImpl$$Lambda$240.1792488288.handle
at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1107)
at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:151)
at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:133)
at io.vertx.ext.web.handler.impl.BodyHandlerImpl$BHandler.doEnd(BodyHandlerImpl.java:313)
at io.vertx.ext.web.handler.impl.BodyHandlerImpl$BHandler.end(BodyHandlerImpl.java:290)
at io.vertx.ext.web.handler.impl.BodyHandlerImpl.lambda$handle$0(BodyHandlerImpl.java:86)
at io.vertx.ext.web.handler.impl.BodyHandlerImpl$$Lambda$352.1411758209.handle
at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:96)
at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:59)
at io.vertx.core.http.impl.HttpEventHandler.handleEnd(HttpEventHandler.java:76)
at io.vertx.core.http.impl.Http2ServerRequest.handleEnd(Http2ServerRequest.java:245)
at io.vertx.core.http.impl.VertxHttp2Stream.lambda$new$1(VertxHttp2Stream.java:62)
at io.vertx.core.http.impl.VertxHttp2Stream$$Lambda$345.1645604549.handle
at io.vertx.core.streams.impl.InboundBuffer.handleEvent(InboundBuffer.java:240)
at io.vertx.core.streams.impl.InboundBuffer.write(InboundBuffer.java:130)
at io.vertx.core.http.impl.VertxHttp2Stream$$Lambda$348.1476883151.handle
at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:96)
at io.vertx.core.impl.WorkerContext.lambda$emit$0(WorkerContext.java:78)
at io.vertx.core.impl.WorkerContext$$Lambda$262.2104941255.handle
at io.vertx.core.impl.WorkerContext.lambda$execute$2(WorkerContext.java:123)
at io.vertx.core.impl.WorkerContext$$Lambda$263.947145485.run
at io.vertx.core.impl.TaskQueue.run(TaskQueue.java:76)
at io.vertx.core.impl.TaskQueue$$Lambda$123.1741786839.run
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:834)
@pantinor pantinor added the bug Something isn't working label Feb 24, 2021
@pantinor pantinor changed the title OPEN A_PI web validation with query parameter using string Enum fails with exception OPEN API web validation with query parameter using string Enum fails with exception Feb 24, 2021
@vietj vietj added this to the 4.0.3 milestone Feb 24, 2021
@slinkydeveloper slinkydeveloper self-assigned this Mar 2, 2021
@slinkydeveloper
Copy link
Member

Can you try to create a full reproducer?

@slinkydeveloper slinkydeveloper added component/openapi and removed bug Something isn't working labels Mar 2, 2021
@pantinor
Copy link
Author

pantinor commented Mar 2, 2021

The issue can be reproduced with attached test.

repro.txt

io.vertx.json.schema.NoSyncValidationException: Trying to execute validateSync() for a Validator in asynchronous state
at io.vertx.json.schema.common.BaseMutableStateValidator.checkSync(BaseMutableStateValidator.java:59)
at io.vertx.json.schema.common.RefSchema.getDefaultValue(RefSchema.java:122)
at io.vertx.ext.web.validation.impl.validator.SchemaValidator.getDefault(SchemaValidator.java:41)
at io.vertx.ext.web.validation.impl.parameter.ParameterProcessorImpl.process(ParameterProcessorImpl.java:43)

@slinkydeveloper
Copy link
Member

slinkydeveloper commented Mar 4, 2021

@pantinor the test you provided is passing to me 😄 Let me try to play around it

@slinkydeveloper
Copy link
Member

Debugging down into it seems to stop at the validator.getDefault line 43 ParameterProcessorImpl.

Ahhhhh i see now. This might be already solved with #1816. Can you try to use 4.0.3-SNAPSHOT in your project to check if you see the problem?

@pantinor
Copy link
Author

Sorry I don't have 4.,0.3 snapshot. Can you try it on your end?

@pantinor
Copy link
Author

Yes that issue you referenced indeed looks like it will address the issue. I would say close this ticket if it works now with 4.0.3!

@vietj vietj modified the milestones: 4.0.3, 4.0.4 Mar 15, 2021
@slinkydeveloper slinkydeveloper modified the milestones: 4.0.4, 4.0.3 Mar 17, 2021
@slinkydeveloper
Copy link
Member

Cool! Reopen if you need it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants