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

Bridge raising access denied exception when missing content-type in the request #598

Closed
ppatierno opened this issue Feb 16, 2022 · 3 comments · Fixed by #714
Closed

Bridge raising access denied exception when missing content-type in the request #598

ppatierno opened this issue Feb 16, 2022 · 3 comments · Fixed by #714

Comments

@ppatierno
Copy link
Member

When an operation against the bridge is executed without specifying the content-type in the header, the following error is logged in the pod and an "Internal Server Error" string is returned to the HTTP client.

2022-02-16 13:38:54 ERROR RoutingContext: - Unhandled exception in router
io.vertx.core.file.FileSystemException: Unable to create folder at path 'file-uploads'
	at io.vertx.core.file.impl.FileSystemImpl$12.perform(FileSystemImpl.java:950) ~[vertx-core-4.2.4.jar:4.2.4]
	at io.vertx.core.file.impl.FileSystemImpl$12.perform(FileSystemImpl.java:932) ~[vertx-core-4.2.4.jar:4.2.4]
	at io.vertx.core.file.impl.FileSystemImpl.mkdirsBlocking(FileSystemImpl.java:345) ~[vertx-core-4.2.4.jar:4.2.4]
	at io.vertx.ext.web.handler.impl.BodyHandlerImpl$BHandler.makeUploadDir(BodyHandlerImpl.java:248) ~[vertx-web-4.2.4.jar:4.2.4]
	at io.vertx.ext.web.handler.impl.BodyHandlerImpl$BHandler.<init>(BodyHandlerImpl.java:186) ~[vertx-web-4.2.4.jar:4.2.4]
	at io.vertx.ext.web.handler.impl.BodyHandlerImpl.handle(BodyHandlerImpl.java:84) ~[vertx-web-4.2.4.jar:4.2.4]
	at io.vertx.ext.web.handler.impl.BodyHandlerImpl.handle(BodyHandlerImpl.java:44) ~[vertx-web-4.2.4.jar:4.2.4]
	at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1212) ~[vertx-web-4.2.4.jar:4.2.4]
	at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:163) [vertx-web-4.2.4.jar:4.2.4]
	at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:141) [vertx-web-4.2.4.jar:4.2.4]
	at io.vertx.ext.web.impl.RouterImpl.handle(RouterImpl.java:67) [vertx-web-4.2.4.jar:4.2.4]
	at io.vertx.ext.web.impl.RouterImpl.handle(RouterImpl.java:37) [vertx-web-4.2.4.jar:4.2.4]
	at io.vertx.core.http.impl.Http1xServerRequestHandler.handle(Http1xServerRequestHandler.java:67) [vertx-core-4.2.4.jar:4.2.4]
	at io.vertx.core.http.impl.Http1xServerRequestHandler.handle(Http1xServerRequestHandler.java:30) [vertx-core-4.2.4.jar:4.2.4]
	at io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:50) [vertx-core-4.2.4.jar:4.2.4]
	at io.vertx.core.impl.DuplicatedContext.emit(DuplicatedContext.java:168) [vertx-core-4.2.4.jar:4.2.4]
	at io.vertx.core.http.impl.Http1xServerConnection.handleMessage(Http1xServerConnection.java:145) [vertx-core-4.2.4.jar:4.2.4]
	at io.vertx.core.net.impl.ConnectionBase.read(ConnectionBase.java:156) [vertx-core-4.2.4.jar:4.2.4]
	at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:153) [vertx-core-4.2.4.jar:4.2.4]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
	at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:93) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
	at io.netty.handler.codec.http.websocketx.extensions.WebSocketServerExtensionHandler.channelRead(WebSocketServerExtensionHandler.java:99) [netty-codec-http-4.1.73.Final.jar:4.1.73.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
	at io.vertx.core.http.impl.Http1xUpgradeToH2CHandler.channelRead(Http1xUpgradeToH2CHandler.java:116) [vertx-core-4.2.4.jar:4.2.4]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:327) [netty-codec-4.1.73.Final.jar:4.1.73.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:314) [netty-codec-4.1.73.Final.jar:4.1.73.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:435) [netty-codec-4.1.73.Final.jar:4.1.73.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:279) [netty-codec-4.1.73.Final.jar:4.1.73.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
	at io.vertx.core.http.impl.Http1xOrH2CHandler.end(Http1xOrH2CHandler.java:61) [vertx-core-4.2.4.jar:4.2.4]
	at io.vertx.core.http.impl.Http1xOrH2CHandler.channelRead(Http1xOrH2CHandler.java:38) [vertx-core-4.2.4.jar:4.2.4]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:722) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:658) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:584) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496) [netty-transport-4.1.73.Final.jar:4.1.73.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986) [netty-common-4.1.73.Final.jar:4.1.73.Final]
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [netty-common-4.1.73.Final.jar:4.1.73.Final]
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-common-4.1.73.Final.jar:4.1.73.Final]
	at java.lang.Thread.run(Thread.java:829) [?:?]
Caused by: java.nio.file.AccessDeniedException: /opt/strimzi/file-uploads
	at sun.nio.fs.UnixException.translateToIOException(UnixException.java:90) ~[?:?]
	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111) ~[?:?]
	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116) ~[?:?]
	at sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:389) ~[?:?]
	at java.nio.file.Files.createDirectory(Files.java:690) ~[?:?]
	at java.nio.file.Files.createAndCheckIsDirectory(Files.java:797) ~[?:?]
	at java.nio.file.Files.createDirectories(Files.java:783) ~[?:?]
	at io.vertx.core.file.impl.FileSystemImpl$12.perform(FileSystemImpl.java:940) ~[vertx-core-4.2.4.jar:4.2.4]
	... 55 more

The above error was raised by issuing the following example request via cURL where the content-type is missing.

curl -X POST \
  http://localhost:8080/topics/my-topic \
  -d '{
    "records": [
        {
            "key": "key-1",
            "value": "value-1"
        },
        {
            "key": "key-2",
            "value": "value-2"
        }
    ]
}'

By adding the line -H 'content-type: application/vnd.kafka.json.v2+json' the operation works fine.

My feeling is that the Vert.x router is defaulting to some "built-in" route which tries to create a file-uploads folder in a read-only /opt/strimzi/ path on the pod, when it's not able to route the request properly due to the missing content-type because how it's defined in the OpenAPI specification.

@scholzj
Copy link
Member

scholzj commented Feb 16, 2022

I guess we can try to capture these and return some nicer error :-D

@ppatierno
Copy link
Member Author

Of course we can ... and we should :-D

@scholzj
Copy link
Member

scholzj commented Feb 16, 2022

We should come up with some wanna be funny error message like Google has ;-)

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

Successfully merging a pull request may close this issue.

2 participants