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

resolves #853 print an explicit error message when the URI is too long (414) #869

Merged
merged 1 commit into from
Aug 27, 2021

Conversation

ggrossetie
Copy link
Member

@ggrossetie ggrossetie commented Aug 22, 2021

Before

HTTP/1.0 414 Request-URI Too Long
content-length: 0

(nothing in the server log)

After

HTTP/1.0 414 Request-URI Too Long
content-length: 229
content-type: text/plain

Error 414: The request URI's length exceeds 4096. You can update this value by setting KROKI_MAX_URI_LENGTH environment variable. Please read: https://docs.kroki.io/kroki/setup/configuration/#_max_uri_length for more information.
{
  "timestamp": "1629626401216",
  "level": "ERROR",
  "thread": "vert.x-eventloop-thread-1",
  "mdc": {
    "error_message": "The request URI's length exceeds 4096. You can update this value by setting KROKI_MAX_URI_LENGTH environment variable. Please read: https://docs.kroki.io/kroki/setup/configuration/#_max_uri_length for more information.",
    "path": "/bad-request",
    "method": "GET",
    "action": "error",
    "error_code": "414",
    "failure_class_name": "io.netty.handler.codec.TooLongFrameException"
  },
  "logger": "io.kroki.server.error.ErrorHandler",
  "message": "An error occurred",
  "context": "default",
  "exception": "io.netty.handler.codec.TooLongFrameException: An HTTP line is larger than 4096 bytes.\n\tat io.netty.handler.codec.http.HttpObjectDecoder$LineParser.newException(HttpObjectDecoder.java:983)\n\tat io.netty.handler.codec.http.HttpObjectDecoder$HeaderParser.increaseCount(HttpObjectDecoder.java:946)\n\tat io.netty.handler.codec.http.HttpObjectDecoder$HeaderParser.process(HttpObjectDecoder.java:934)\n\tat io.netty.handler.codec.http.HttpObjectDecoder$LineParser.process(HttpObjectDecoder.java:978)\n\tat io.netty.buffer.AbstractByteBuf.forEachByteAsc0(AbstractByteBuf.java:1301)\n\tat io.netty.buffer.AbstractByteBuf.forEachByte(AbstractByteBuf.java:1281)\n\tat io.netty.handler.codec.http.HttpObjectDecoder$HeaderParser.parse(HttpObjectDecoder.java:908)\n\tat io.netty.handler.codec.http.HttpObjectDecoder$LineParser.parse(HttpObjectDecoder.java:965)\n\tat io.netty.handler.codec.http.HttpObjectDecoder.decode(HttpObjectDecoder.java:236)\n\tat io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:507)\n\tat io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:446)\n\tat io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)\n\tat io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)\n\tat io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)\n\tat io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)\n\tat io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719)\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655)\n\tat io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581)\n\tat io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)\n\tat io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)\n\tat io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)\n\tat io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)\n\tat java.base/java.lang.Thread.run(Unknown Source)\n"
}

resolves #853

TODO

  • Add a test case

@ggrossetie
Copy link
Member Author

Vert.x seems to replace the route (i.e. path) by /bad-request, I think we should preserve the initial value to avoid confusion.

@ggrossetie ggrossetie force-pushed the issue-853-uri-too-long branch from 43f3dd1 to 7f59237 Compare August 22, 2021 10:07
@ggrossetie
Copy link
Member Author

Actually we cannot preserve the initial URI since the URI is too long to be read!

@ggrossetie ggrossetie force-pushed the issue-853-uri-too-long branch from 7f59237 to 5366bc2 Compare August 22, 2021 12:44
@ggrossetie ggrossetie merged commit 8d87c48 into yuzutech:main Aug 27, 2021
@ggrossetie ggrossetie deleted the issue-853-uri-too-long branch August 27, 2021 11:22
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 this pull request may close these issues.

Print an explicit error message when the URI is too long (414)
1 participant