Skip to content

HDDS-17571. S3 Gateway should return 400 instead of 500 when Host matches no ozone.s3g.domain.name - #11854

Merged
adoroszlai merged 1 commit into
apache:masterfrom
smengcl:HDDS-17571
Oct 31, 2026
Merged

adoroszlai merged 1 commit into
apache:masterfrom
smengcl:HDDS-17571

Conversation

@smengcl

@smengcl smengcl commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Generated-by: Claude Code (Opus 5.5)

What changes were proposed in this pull request?

When ozone.s3g.domain.name is set and the Host header (port stripped) matches none of the configured domains, VirtualHostStyleFilter throws org.apache.hadoop.fs.InvalidRequestException. It is not an OS3Exception, so the client gets HTTP 500 with no S3 error body. The same applies to a virtual host style Host with no dot before the domain.

AWS SDKs and S3A retry 500s, so a configuration mistake shows up as a slow failure that looks like a hang. For example, if the gateway's own FQDN is missing from the domain list, every path style request to it (including a health probe HEAD /) fails with 500.

This patch keeps rejecting those requests but returns an S3 400 InvalidRequest naming the rejected host, using S3ErrorTable and wrapOS3Exception the same way AuthorizationFilter does, so clients fail fast with a clear error. The configured domain list and the request URI are logged at debug level instead of being returned, since the client is not authenticated at this point.

Treating an unmatched Host as path style was considered instead, but then a virtual host style request sent to an unlisted host name would be read as a different operation (for example DELETE bucket.host/key would become DeleteBucket key).

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-17571

How was this patch tested?

Extended TestVirtualHostStyleFilter: the existing rejection cases (including the IPv6 ones) now assert a 400 InvalidRequest, and a new case covers a path style request whose Host is missing from the domain list.

🤖 Generated with Claude Code

…o ozone.s3g.domain.name

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings October 30, 2026 01:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@github-actions github-actions Bot added the s3 S3 Gateway label Oct 30, 2026
@smengcl smengcl changed the title HDDS-17571. S3 Gateway returns 500 instead of 400 when Host matches no ozone.s3g.domain.name HDDS-17571. S3 Gateway should return 400 instead of 500 when Host matches no ozone.s3g.domain.name Oct 30, 2026
@adoroszlai
adoroszlai marked this pull request as ready for review October 31, 2026 12:53
@adoroszlai
adoroszlai merged commit ef63bac into apache:master Oct 31, 2026
154 of 155 checks passed
@adoroszlai

Copy link
Copy Markdown
Contributor

Thanks @smengcl for the patch.

@smengcl

smengcl commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @adoroszlai for the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

s3 S3 Gateway

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants