vert-x3 / vertx-web

HTTP web applications for Vert.x
Apache License 2.0
1.11k stars 531 forks source link

Open Api Service - Missing Form Attributes after Vert.x Update #2238

Open webnobis opened 2 years ago

webnobis commented 2 years ago

We defined a Yaml Open Api 3.0 like the project description.

Problem

Missing expected form attributes, requests fails.

Reproduction

To reproduce the bug, please use my example project: webnobis-vertx-open-api2

Steps to reproduce

  1. Check out the example project
  2. To test with Vert.x 4.3.2, use the feature branch
  3. To test with Vert.x 4.3.0, use the master
  4. Execute the JUnit test, either with ./gradlew test or within a IDE
  5. Show log outputs

Behavior with Vert.x 4.3.2

After sending form attributes over the generated service, no form attributes exists, the request fails: Junit-Test-Vert.x-4.3.2 ______________Missing form attributes_______________ Unhandled exception in router io.vertx.ext.web.validation.BodyProcessorException: [Bad Request] Validation error for body application/x-www-form-urlencoded: provided object should contain property charset at io.vertx.ext.web.validation.BodyProcessorException.createValidationError(BodyProcessorException.java:64) ~[vertx-web-validation-4.3.2.jar:4.3.2] at io.vertx.ext.web.validation.impl.body.FormBodyProcessorImpl.lambda$process$0(FormBodyProcessorImpl.java:47)

Behavior with Vert.x 4.3.0

If we used Vert.x 4.3.0, the form attributes are available and the request is success: JUnit-Test-Vert.x-4.3.0 ______________Form attributes: id=the-id|content=the real content|charset=UTF-8 BUILD SUCCESSFUL in 1s Log-Output-Implementation

chris-brace commented 2 years ago

do you think this might be related to what im seeing? https://github.com/vert-x3/vertx-web/issues/2220 . there doesn't seem to be a lot of throughput on bugs in this repo.

webnobis commented 2 years ago

@chris-brace, yes, files fields are also form fields.

I found this days a workaround, to could use newer Vert.x versions also with the form fields: // Overwrite Body handler, because of https://github.com/vert-x3/vertx-web/issues/2238 .map(RouterBuilder::mountServicesFromExtensions) .map(routerBuilder -> routerBuilder.rootHandler(BodyHandler.create())) .map(RouterBuilder::createRouter)

chris-brace commented 2 years ago

ooo thank you i will try this when i get some time

chris-brace commented 2 years ago

@webnobis this fixed it for me