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

[bug] Incorrect AWS URL formatting in BuildAwsUrl #171

Closed
simon-fauconnier opened this issue Aug 27, 2024 · 2 comments · Fixed by #172
Closed

[bug] Incorrect AWS URL formatting in BuildAwsUrl #171

simon-fauconnier opened this issue Aug 27, 2024 · 2 comments · Fixed by #172

Comments

@simon-fauconnier
Copy link

Description:

Hello,

I am encountering an issue with AWS URL formatting when using the minio-cpp client. Following the BucketExists example provided in the documentation, an error is raised regarding host resolution.

Code to reproduce the issue

#include <miniocpp/client.h>

int main() {
  // Create S3 base URL.
  minio::s3::BaseUrl base_url("s3.eu-central-1.amazonaws.com");

  // Create credential provider.
  minio::creds::StaticProvider provider(
      "****", "****");

  // Create S3 client.
  minio::s3::Client client(base_url, &provider);

  // Create bucket exists arguments.
  minio::s3::BucketExistsArgs args;
  args.bucket = "test";

  // Call bucket exists.
  minio::s3::BucketExistsResponse resp = client.BucketExists(args);

  // Handle response.
  if (resp) {
    if (resp.exist) {
      std::cout << "my-bucket exists" << std::endl;
    } else {
      std::cout << "my-bucket does not exist" << std::endl;
    }
  } else {
    std::cout << "unable to do bucket existence check; "
              << resp.Error().String() << std::endl;
  }

  return 0;
}

Debugging Output

When client.Debug(true); is enabled, the following output is observed:

* Could not resolve host: sa-soundnodes.eu-central-1.amazonaws.comeu-central-1.amazonaws.com
* Closing connection 0
unable to do bucket existence check; server failed with HTTP status code 0

It seems that the AWS URL is not formatted correctly, leading to a concatenated host name that cannot be resolved (sa-soundnodes.eu-central-1.amazonaws.comeu-central-1.amazonaws.com).

Expected Behavior

The client should properly format the AWS URL so that the host resolves correctly.

Comparison with Python Client

I do not have this issue when using the Python client for MinIO. The following Python code works correctly without any host resolution problems:

from minio import Minio

client = Minio("s3.eu-central-1.amazonaws.com",
    access_key="****",
    secret_key="****",
)

bucket_name = "test"

found = client.bucket_exists(bucket_name)
if not found:
    print("Bucket not exists", bucket_name)
else:
    print("Bucket", bucket_name, "already exists")

The Python client successfully checks the existence of the bucket without any issues.

Environment

  • minio-cpp version: 0.3.0
  • Operating system: Ubuntu 22.04.3 LTS
  • Compiler: gcc version 11.4.0
balamurugana added a commit to balamurugana/minio-cpp that referenced this issue Aug 27, 2024
@balamurugana
Copy link
Member

@simon-fauconnier Please try the fix #172

@simon-fauconnier
Copy link
Author

The fix #172 solves the issue

Thanks @balamurugana !

harshavardhana pushed a commit that referenced this issue Aug 27, 2024
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