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

ListBucketsCommand: Request with GET/HEAD method cannot have body #1633

Closed
jzillmann opened this issue Oct 28, 2020 · 2 comments · Fixed by #1698
Closed

ListBucketsCommand: Request with GET/HEAD method cannot have body #1633

jzillmann opened this issue Oct 28, 2020 · 2 comments · Fixed by #1698
Assignees
Labels
bug This issue is a bug. High Priority

Comments

@jzillmann
Copy link

jzillmann commented Oct 28, 2020

Describe the bug
Inside a browser app (inside an electron app as well), i tried:

import { S3Client, ListBucketsCommand } from "@aws-sdk/client-s3";
const client = new S3Client({
  region: "eu-central-1",
  credentials: {
    accessKeyId: "xxx",
    secretAccessKey: "***",
  },
});
const result = client
  .send(new ListBucketsCommand({}))
  .catch((e) => console.log(e));

The error i'm getting is as follow:

TypeError: Failed to construct 'Request': Request with GET/HEAD method cannot have body.
at FetchHttpHandler.handle (fetch-http-handler.js:41)
at ListBucketsCommand.js:29
at deserializerMiddleware.js:8
at step (tslib.es6.js:100)
at Object.next (tslib.es6.js:81)
at tslib.es6.js:74
at new Promise (<anonymous>)
at __awaiter$j (tslib.es6.js:70)
at deserializerMiddleware.js:2
at middleware.js:36

When debugging fetch-http-handler.js:41 i can see the requestOptions object has body: "" set.
Changing "" to undefined solves the problem.

SDK version number
@aws-sdk/client-s3 1.0.0-rc.2

Is the issue in the browser/Node.js/ReactNative?
Browser/Node.js (Electron)

Details of the browser/Node.js/ReactNative version

  • Chrome: 86.0.4240.111
  • Electron: 10.1.5

To Reproduce (observed behavior)
not yet

Expected behavior
Executing commands like ListBucketsCommand should set the body.

Screenshots
not yet

Additional context
nothing

@alexforsyth alexforsyth added bug This issue is a bug. High Priority labels Oct 30, 2020
@alexforsyth alexforsyth added the needs-triage This issue or PR still needs to be triaged. label Oct 30, 2020
@AllanZhengYP AllanZhengYP removed the needs-triage This issue or PR still needs to be triaged. label Nov 5, 2020
AllanZhengYP added a commit to AllanZhengYP/smithy-typescript that referenced this issue Nov 18, 2020
fixes: aws/aws-sdk-js-v3#1633
This change doesn't affect RPC protocols because they use
POST all the time
AllanZhengYP added a commit to AllanZhengYP/aws-sdk-js-v3 that referenced this issue Nov 18, 2020
AllanZhengYP added a commit to AllanZhengYP/aws-sdk-js-v3 that referenced this issue Nov 18, 2020
AllanZhengYP added a commit to AllanZhengYP/smithy-typescript that referenced this issue Nov 18, 2020
fixes: aws/aws-sdk-js-v3#1633
This change doesn't affect RPC protocols because they use
POST all the time
AllanZhengYP added a commit to AllanZhengYP/smithy-typescript that referenced this issue Nov 18, 2020
fixes: aws/aws-sdk-js-v3#1633
This change doesn't affect RPC protocols because they use
POST all the time
@AllanZhengYP
Copy link
Contributor

Hi @jzillmann,

I've post a PR removing empty string body fromt he GET/HEAD request. For your information, listBuckets won't work in browser even this fix. Because S3 doesn't support CORS for all bucket level operations(e.g. listBuckets). It may work in Electron.

@github-actions
Copy link

github-actions bot commented Jan 8, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. High Priority
Projects
None yet
3 participants