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

HTTP error (can't write to /deployments/file-uploads) when not setting content-type #634

Closed
nicolaferraro opened this issue Feb 19, 2021 · 9 comments
Labels
kind/bug Something isn't working

Comments

@nicolaferraro
Copy link
Member

I've just added a webhook-source Kamelet in apache/camel-kamelets#14.

When bound with the following binding:

apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
  name: webhook-source-binding
spec:
  source:
    ref:
      kind: Kamelet
      apiVersion: camel.apache.org/v1alpha1
      name: webhook-source
  sink:
    uri: log:info

I've noticed that if I call it with:

curl -X POST -d Ciao -H "Content-Type: text/plain" http://my-route-dns/webhook/

... then everything goes fine. But without the content-type:

curl -X POST -d Ciao http://my-route-dns/webhook/

Then it fails because it probably tries to store some temp data in an illegal location.

Maybe the content is interpreted as a binary file and there's some caching mechanism in place. Maybe we should use a writable dir for that.

webhook-source-binding-55dbdddd6d-jfv8j integration 2021-02-19 14:31:50,135 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (vert.x-eventloop-thread-0) HTTP Request to /webhook/ failed, error id: 046ee4d5-2e80-481e-ace5-cc3d542fa723-1: io.vertx.core.file.FileSystemException: java.nio.file.AccessDeniedException: /deployments/file-uploads
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.vertx.core.file.impl.FileSystemImpl$12.perform(FileSystemImpl.java:747)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.vertx.core.file.impl.FileSystemImpl$12.perform(FileSystemImpl.java:729)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.vertx.core.file.impl.FileSystemImpl.mkdirsBlocking(FileSystemImpl.java:249)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.vertx.ext.web.handler.impl.BodyHandlerImpl$BHandler.makeUploadDir(BodyHandlerImpl.java:236)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.vertx.ext.web.handler.impl.BodyHandlerImpl$BHandler.<init>(BodyHandlerImpl.java:181)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.vertx.ext.web.handler.impl.BodyHandlerImpl.handle(BodyHandlerImpl.java:85)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.vertx.ext.web.handler.impl.BodyHandlerImpl.handle(BodyHandlerImpl.java:42)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.quarkus.vertx.http.runtime.VertxHttpRecorder$16.handle(VertxHttpRecorder.java:1094)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.quarkus.vertx.http.runtime.VertxHttpRecorder$16.handle(VertxHttpRecorder.java:1067)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1036)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:131)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:132)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.quarkus.vertx.http.runtime.VertxHttpRecorder$4.handle(VertxHttpRecorder.java:322)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.quarkus.vertx.http.runtime.VertxHttpRecorder$4.handle(VertxHttpRecorder.java:300)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1036)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:131)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:132)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.vertx.ext.web.impl.RouterImpl.handle(RouterImpl.java:54)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.vertx.ext.web.impl.RouterImpl.handle(RouterImpl.java:36)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.quarkus.vertx.http.runtime.VertxHttpRecorder$9.handle(VertxHttpRecorder.java:412)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.quarkus.vertx.http.runtime.VertxHttpRecorder$9.handle(VertxHttpRecorder.java:409)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.quarkus.vertx.http.runtime.VertxHttpRecorder$1.handle(VertxHttpRecorder.java:141)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.quarkus.vertx.http.runtime.VertxHttpRecorder$1.handle(VertxHttpRecorder.java:126)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.vertx.core.http.impl.WebSocketRequestHandler.handle(WebSocketRequestHandler.java:50)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.vertx.core.http.impl.WebSocketRequestHandler.handle(WebSocketRequestHandler.java:32)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.vertx.core.http.impl.Http1xServerConnection.handleMessage(Http1xServerConnection.java:136)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:366)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.vertx.core.impl.EventLoopContext.execute(EventLoopContext.java:43)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:229)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:163)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:93)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.handler.codec.http.websocketx.extensions.WebSocketServerExtensionHandler.channelRead(WebSocketServerExtensionHandler.java:101)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.vertx.core.http.impl.Http1xUpgradeToH2CHandler.channelRead(Http1xUpgradeToH2CHandler.java:109)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:311)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:425)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.vertx.core.http.impl.Http1xOrH2CHandler.end(Http1xOrH2CHandler.java:61)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.vertx.core.http.impl.Http1xOrH2CHandler.channelRead(Http1xOrH2CHandler.java:38)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
webhook-source-binding-55dbdddd6d-jfv8j integration     at java.base/java.lang.Thread.run(Thread.java:834)
webhook-source-binding-55dbdddd6d-jfv8j integration Caused by: java.nio.file.AccessDeniedException: /deployments/file-uploads
webhook-source-binding-55dbdddd6d-jfv8j integration     at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:90)
webhook-source-binding-55dbdddd6d-jfv8j integration     at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
webhook-source-binding-55dbdddd6d-jfv8j integration     at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
webhook-source-binding-55dbdddd6d-jfv8j integration     at java.base/sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:389)
webhook-source-binding-55dbdddd6d-jfv8j integration     at java.base/java.nio.file.Files.createDirectory(Files.java:690)
webhook-source-binding-55dbdddd6d-jfv8j integration     at java.base/java.nio.file.Files.createAndCheckIsDirectory(Files.java:797)
webhook-source-binding-55dbdddd6d-jfv8j integration     at java.base/java.nio.file.Files.createDirectories(Files.java:783)
webhook-source-binding-55dbdddd6d-jfv8j integration     at io.vertx.core.file.impl.FileSystemImpl$12.perform(FileSystemImpl.java:737)
webhook-source-binding-55dbdddd6d-jfv8j integration     ... 74 more
webhook-source-binding-55dbdddd6d-jfv8j integration 
@nicolaferraro nicolaferraro added the kind/bug Something isn't working label Feb 19, 2021
@lburgazzoli
Copy link
Contributor

@ppalaga @jamesnetherton

@davsclaus
Copy link
Contributor

Yeah without the content-type then the message body is null

2022-04-12 10:00:34.874  INFO 26325 --- [           main] org.apache.camel.main.VertxHttpServer    : HTTP endpoints summary
2022-04-12 10:00:34.875  INFO 26325 --- [           main] org.apache.camel.main.VertxHttpServer    :     http://0.0.0.0:8080/webhook
2022-04-12 10:00:51.534  INFO 26325 --- [worker-thread-0] info                                     : Exchange[ExchangePattern: InOut, BodyType: io.vertx.core.buffer.impl.BufferImpl, Body: Ciao]
2022-04-12 10:01:11.838  INFO 26325 --- [worker-thread-1] info                                     : Exchange[ExchangePattern: InOut, BodyType: null, Body: [Body is null]]
2022-04-12 10:02:08.543  INFO 26325 --- [worker-thread-2] info                                     : Exchange[ExchangePattern: InOut, BodyType: null, Body: [Body is null]]
2022-04-12 10:02:15.619  INFO 26325 --- [worker-thread-3] info                                     : Exchange[ExchangePattern: InOut, BodyType: null, Body: [Body is null]]
2022-04-12 10:02:22.396  INFO 26325 --- [worker-thread-4] info                                     : Exchange[ExchangePattern: InOut, BodyType: io.vertx.core.buffer.impl.BufferImpl, Body: Ciao2]

The stacktrace is no longer, but platform-http-vertx seems to not want to read the message body because there is no content-type header. We may want to relax this so it works like other camel http components.

@davsclaus
Copy link
Contributor

It is CURL that uses this content-type when you don't specify it.

Content-Type -> application/x-www-form-urlencoded

And since the data is not a key=value (not form data) then the body is null

@davsclaus
Copy link
Contributor

So it is because platform-http have file-uploads enabled out of the box, which webhook should disable.

@davsclaus
Copy link
Contributor

Its a general problem for camel-k with platform-http-vertx where vertx would store form-data to disk. I cant see a desire to want this in camel-k style integrations where uploads would be stored to a temp folder.

@davsclaus
Copy link
Contributor

I created a JIRA ticket in camel core project
https://issues.apache.org/jira/browse/CAMEL-17944

@davsclaus
Copy link
Contributor

@lburgazzoli yeah its a 1 year old bug, any comments?

@lburgazzoli
Copy link
Contributor

yeah, I think this bug was meant to be addressed by camel or camel-quarkus, I think we can close ti

@davsclaus
Copy link
Contributor

Ok tracked by that CAMEL ticket

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants