Skip to content

Conversation

@trim21
Copy link
Contributor

@trim21 trim21 commented Jun 2, 2023

s3 doesn't always return bucket region, need to fallback to default region.

This bug is added by #1156

Copy link
Contributor

@aldy505 aldy505 left a comment

Choose a reason for hiding this comment

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

LGTM. this means we got to do more integration testing

@prakashsvmx
Copy link
Member

without region specified, the following is the error . so looks like the default region is not applied.

REQUEST: GET /sph-test-inc-upld?location
host: s3.amazonaws.com
user-agent: MinIO (linux; x64) minio-js/7.1.2
x-amz-date: 20230605T045033Z
x-amz-content-sha256: UNSIGNED-PAYLOAD
authorization: AWS4-HMAC-SHA256 Credential=AKIA3WNQJCXE4ABTFTFC/20230605/us-east-1/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=**REDACTED**

RESPONSE: 200
x-amz-id-2: 4gitFRKsCSgBVuCB/g3jBYKGaNmY9RKUIMLED96YYMXn42l+7kVjQMOO1I+zrPqTgm/q5teFTDk=
x-amz-request-id: 4S0ZJQQD82Q6FCEE
date: Mon, 05 Jun 2023 04:50:35 GMT
content-type: application/xml
transfer-encoding: chunked
server: AmazonS3
connection: close

S3Error: 400
    at Object.parseResponseError (/home/prakash/MinIO/GIT/sdks/minio-js/dist/main/internal/xml-parser.js:81:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Client.makeRequestStreamAsync (/home/prakash/MinIO/GIT/sdks/minio-js/dist/main/internal/client.js:465:19) {
  code: 'UnknownError',
  amzRequestid: '5J4QC1SBHWPYKQ5N',
  amzId2: 'Y6kK3VW9YS3LCsL0Ez0QtczQxRhI9dvOE241F5qJbkTo9kOgv/wknCQJ87hG+jNflAaWHVE0EqU=',
  amzBucketRegion: undefined,
  [cause]: {
    amzRequestid: '5J4QC1SBHWPYKQ5N',
    amzId2: 'Y6kK3VW9YS3LCsL0Ez0QtczQxRhI9dvOE241F5qJbkTo9kOgv/wknCQJ87hG+jNflAaWHVE0EqU=',
    amzBucketRegion: undefined
  }
}

@trim21
Copy link
Contributor Author

trim21 commented Jun 6, 2023

should be fixed

import * as Minio from './src/minio.js'

var s3Client = new Minio.Client({
  endPoint: 's3.amazonaws.com',
  accessKey: '...',
  secretKey: '...',
  // region: 'us-east-1',
  // pathStyle: true,
  // useSSL: true,
})

s3Client.statObject("minio-js-test-3eb80d62-0df6-42d4-853f-e220e24ec9af-region-1", "51420856.jpg").then(o => {
  console.log(o)
}).catch(e => {
  throw e
})

Copy link
Member

@prakashsvmx prakashsvmx left a comment

Choose a reason for hiding this comment

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

Tested. LGTM 👍

mc mb --region=us-west-2 s3/sph-region-bucket

 ➜ mc cp ~/Pictures/10.png s3/sph-region-bucket/1.png

 var s3Client = new Minio.Client({
  endPoint: 's3.amazonaws.com',
  accessKey: 's3AccesKey',
  secretKey: 's3Secretkey,
  region: 'us-west-2',// with/without/default region.
  //pathStyle: true,
  //useSSL: true,
})

Copy link
Contributor

@aldy505 aldy505 left a comment

Choose a reason for hiding this comment

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

LGTM

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.

4 participants