Skip to content

When using netty 4.2.8.Final and higher - Will throw error for encoded paths #6673

@nischit7

Description

@nischit7

Describe the bug

The issue is particularly found when one tends to use Netty 4.2.8.Final and higher.
A new change has been added in netty
https://github.com/netty/netty/blob/4.2/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpRequest.java#L94

Specifically in DefaultHttpRequest constructor.
It tries to check for invalid characters in the http path.

When using AWS Bedrock SDK, modelId is sent as a path param. The model Id ARN contains colons. AWS SDK by default tries to encode the path.

The issue starts when RequestAdaptor https://github.com/netty/netty/blob/4.2/codec-http/src/main/java/io/netty/handler/codec/http/DefaultHttpRequest.java#L94
initializes Netty object as below -

DefaultHttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, method, uri, headers);

This constructor has been in use for many years.
But the new change in Netty lib now enforces the below code flow within DefaultHttpRequest

if (validateRequestLine) {
    HttpUtil.validateRequestLineTokens(method, uri);
}

Since Bedrock Model ARN is encoded and is part of the path, it ends up throwing an error - "IllegalArgumentException; The URI contain illegal characters".

We had to downgrade netty lib to 4.2.7.final to get around the issue. A temporary approach.
However a fix is needed in AWS SDK to either the call the new constructor of DefaultHttpRequest to not validate the url or fix the encoding logic.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

The AWS Bedrock streaming should pass without any such client side issues.

Current Behavior

The client side ends up getting an error thrown by Netty as below -
"IllegalArgumentException; The URI contain illegal characters".

Reproduction Steps

Reproducing is easy.
Use AWS Bedrock streaming.
Use Netty 4.2.8.Final version.
Initiate a call for any model ARN.
It will fail

Possible Solution

Solution suggested in the description

Additional Information/Context

No response

AWS Java SDK version used

2.30.6

JDK version used

21

Operating System and version

Linux

Metadata

Metadata

Assignees

Labels

Netty NIO ClientbugThis issue is a bug.p2This is a standard priority issueresponse-requestedWaiting on additional info and feedback. Will move to "closing-soon" in 10 days.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions