Skip to content

[Bug] - REST - invalid method returns plaintext error #1846

@lrm25

Description

@lrm25

Describe the bug
If the method type (e.g. normally GET, PUT, is invalid), versitygw returns this:

HTTP/1.1 400 Bad Request
   Server: VERSITYGW
   Date: Thu, 12 Feb 2026 18:44:06 GMT
   Content-Type: text/plain; charset=utf-8
   Content-Length: 19
   Connection: close
   
   Invalid http method

The error is returned in plaintext. S3 returns this:

HTTP/1.1 400 Bad Request
   Date: Thu, 12 Feb 26 18:47:31 GMT
   Connection: close
   Transfer-Encoding: chunked
   x-amz-id-2: 0vp3gbP+bY8ymlv3nsCGa5EiC8RhZkGLuW7ErRmriUbVrFth0HoNfbpQPJfGxLMA44Sgbq8Lj5EU8t7dHVXSbVof2gPmRKB7hrm2Zq2Jgq+vZH2kF3OQeQ==
   x-amz-request-id: 2CFB9A8897982AAD
   Content-Type: application/xml
   Server: AmazonS3
   
   <?xml version="1.0" encoding="UTF-8"?><Error><Code>BadRequest</Code><Message>An error occurred when parsing the HTTP request.</Message><RequestId>2CFB9A8897982AAD</RequestId><HostId>0vp3gbP+bY8ymlv3nsCGa5EiC8RhZkGLuW7ErRmriUbVrFth0HoNfbpQPJfGxLMA44Sgbq8Lj5EU8t7dHVXSbVof2gPmRKB7hrm2Zq2Jgq+vZH2kF3OQeQ==</HostId></Error>

The versitygw error is actually more clear, but it's in plaintext.

To Reproduce

  1. Start versitygw, e.g.: ./versitygw --access=AKIA**** --secret=******** --region=us-east-1 --cert /Users/lukemccrone/devel/versitygw/cert.pem --key /Users/lukemccrone/devel/versitygw/versitygw.pem posix --versioning-dir /tmp/versioning /tmp/gw
  2. Create a bucket, e.g.: curl -ks -w %{http_code} -X PUT https://localhost:7070/versity-gwtest-bucket-one-1-20260212154404 -H Authorization: AWS4-HMAC-SHA256 Credential=AKIA6****/20260212/us-east-1/s3/aws4_request,SignedHeaders=host;x-amz-content-sha256;x-amz-date,Signature=ddb2e5e7c773bd8c4b7be2887dade60c206cf76d38e711196833ba03a66bc6d0 -H host: localhost:7070 -H x-amz-content-sha256: UNSIGNED-PAYLOAD -H x-amz-date: 20260212T184405Z -o /Users/lukemccrone/devel/versitygw/versity-gwtest-files/output.txt
  3. Send a command with an invalid method to this bucket, e.g.: curl -iks -X INVALID https://localhost:7070/versity-gwtest-bucket-one-1-20260212154404 -H Authorization: AWS4-HMAC-SHA256 Credential=AKIA6****/20260212/us-east-1/s3/aws4_request,SignedHeaders=host;x-amz-content-sha256;x-amz-date,Signature=8bf7e556a6207083f6816079adb9fa6a09347245e1d9421778488cdd83b578ea -H host: localhost:7070 -H x-amz-content-sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 -H x-amz-date: 20260212T184406Z

Expected behavior
An XML error is returned.

Server Version
Version : v1.2.0
Build : d214559
BuildTime: 2026-02-11_06:05:08PM
Darwin Lukes-MacBook-Pro.local 24.6.0 Darwin Kernel Version 24.6.0: Mon Jul 14 11:28:30 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6030 arm64

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions