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

[s3.copyObject]: Invalid character in header content ["x-amz-copy-source"] #6596

Open
3 of 4 tasks
shadoworion opened this issue Oct 29, 2024 · 5 comments
Open
3 of 4 tasks
Assignees
Labels
bug This issue is a bug. p2 This is a standard priority issue service-api This issue is due to a problem in a service API, not the SDK implementation.

Comments

@shadoworion
Copy link

Checkboxes for prior research

Describe the bug

It looks like the "copyObject" function does not support Hebrew in the location path.

Regression Issue

  • Select this option if this issue appears to be a regression.

SDK version number

@aws-sdk/[email protected]

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

22.8.0

Reproduction Steps

const oldLocation = "Files/ce59edb1-c78a-4e47-9cc1-b631b3f6e03b/דוד-טסט_orders_2024-10-28 (2).csv";
const newLocation = "Files/236bf060-db65-45fb-be2a-8d5845a75f6d/דוד-טסט_orders_2024-10-28 (2).csv";

await s3.copyObject({
      CopySource: `${process.env.AWS_STORAGE_BUCKET}/${oldLocation}`,
      Bucket: process.env.AWS_STORAGE_BUCKET,
      Key: newLocation,
});

Observed Behavior

TypeError: Invalid character in header content ["x-amz-copy-source"]
    at ClientRequest.setHeader (node:_http_outgoing:702:3)
    at new ClientRequest (node:_http_client:295:14)
    at request (node:https:379:10)
    at /backend/node_modules/@smithy/node-http-handler/dist-cjs/index.js:349:19
    at new Promise (<anonymous>)
    at _NodeHttpHandler.handle (/backend/node_modules/@smithy/node-http-handler/dist-cjs/index.js:283:12)
    at /backend/node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/index.js:534:18
    at /backend/node_modules/@smithy/middleware-serde/dist-cjs/index.js:33:24
    at /backend/node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/index.js:485:18
    at /backend/node_modules/@smithy/middleware-retry/dist-cjs/index.js:320:38 {
  code: 'ERR_INVALID_CHAR',
  '$metadata': { attempts: 1, totalRetryDelay: 0 }
}

Expected Behavior

Not to get an error

Possible Solution

No response

Additional Information/Context

No response

@shadoworion shadoworion added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 29, 2024
@zshzbh zshzbh self-assigned this Oct 31, 2024
@zshzbh
Copy link
Contributor

zshzbh commented Nov 1, 2024

Hey @shadoworion ,

I can reproduce this issue

import { S3Client, GetObjectCommand, CopyObjectCommand } from "@aws-sdk/client-s3";

// Initialize the S3 client
const s3Client = new S3Client({
  region: "us-east-1", // Replace with your region
});
const copyObjectCommand = new CopyObjectCommand({
  CopySource: `new-bucket-maggie-ma/דוד-טסט_`,
  Bucket: "new-bucket-maggie-ma",
  Key: "דוד-טסט_new",
});
const resCopyObject = await s3Client.send(copyObjectCommand);
console.log(resCopyObject);

The error I got

node:_http_outgoing:662
  validateHeaderValue(name, value);
  ^

TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["x-amz-copy-source"]
    at ClientRequest.setHeader (node:_http_outgoing:662:3)
    at new ClientRequest (node:_http_client:289:14)
    at request (node:https:379:10)
    at /Users/zshzbh/Desktop/newProj/node_modules/@smithy/node-http-handler/dist-cjs/index.js:349:19
    at new Promise (<anonymous>)
    at _NodeHttpHandler.handle (/Users/zshzbh/Desktop/newProj/node_modules/@smithy/node-http-handler/dist-cjs/index.js:283:12)
    at /Users/zshzbh/Desktop/newProj/node_modules/@smithy/smithy-client/dist-cjs/index.js:197:35
    at /Users/zshzbh/Desktop/newProj/node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/index.js:534:24
    at /Users/zshzbh/Desktop/newProj/node_modules/@smithy/middleware-serde/dist-cjs/index.js:33:30
    at /Users/zshzbh/Desktop/newProj/node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/index.js:485:24 {
  code: 'ERR_INVALID_CHAR',
  '$metadata': { attempts: 1, totalRetryDelay: 0 }
}

I will reach out to service team and check if there's an updates. Thanks!

@zshzbh zshzbh added p2 This is a standard priority issue service-api This issue is due to a problem in a service API, not the SDK implementation. and removed needs-triage This issue or PR still needs to be triaged. labels Nov 1, 2024
@shadoworion
Copy link
Author

Hey @zshzbh

Any updates?

@zshzbh
Copy link
Contributor

zshzbh commented Dec 2, 2024

Hey @shadoworion .

I haven't got back from service team, I will follow up this issue with them. Internal ref- V1599096015

Thanks!
Maggie

@Nitro-N
Copy link

Nitro-N commented Dec 12, 2024

@shadoworion @zshzbh, try to wrap CopySource and Key value with encodeURI function

@zshzbh
Copy link
Contributor

zshzbh commented Jan 3, 2025

@Nitro-N Thanks for the workaround solution. I think we can use the encode function as a workaround now, but still I want to let the service team know this issue. I have not received anything from service team yet, will try to reach out again.

Sorry for the wait and thanks for the provided workaround

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p2 This is a standard priority issue service-api This issue is due to a problem in a service API, not the SDK implementation.
Projects
None yet
Development

No branches or pull requests

3 participants