-
Notifications
You must be signed in to change notification settings - Fork 611
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Invalid character in header content [\"user-agent\"] when using ScanCommand from client-dynamodb #6943
Comments
Hey @verebes1 , I can't reproduce this issue. And I'm able to a 200 response. Could you please add ddbDocumentClient.middlewareStack.add(
(next) => async (args) => {
// Log request headers before the request is sent
console.log('Request details:', {
headers: args.request?.headers,
method: args.request?.method,
url: args.request?.url
});
const result = await next(args);
// Log response details if needed
console.log('Response metadata:', result.output?.$metadata);
return result;
},
{
name: "logRequestDetails",
step: "build"
}
); I'm also sharing my code with middlewareStack logging to log the request header. import { DynamoDBClient, GetItemCommand } from "@aws-sdk/client-dynamodb";
import { DynamoDBDocumentClient, GetCommand } from "@aws-sdk/lib-dynamodb";
export const handler = async (event) => {
// TODO implement
console.log('Full event object:', JSON.stringify(event, null, 2));
try {
const ddb = new DynamoDBClient({ region: "us-east-1" });
const ddbDocumentClient = DynamoDBDocumentClient.from(ddb);
ddbDocumentClient.middlewareStack.add(
(next) => async (args) => {
// Modify request headers
// args.request.headers = {
// ...args.request.headers,
// 'x-custom-timestamp': new Date().toISOString(),
// 'x-custom-request-id': `req-${Date.now()}`,
// 'x-application-name': 'my-lambda-function',
// };
// Log headers before request
console.log('Request Headers:', args.request.headers);
// Log request headers before the request is sent
console.log('Request details:', {
headers: args.request?.headers,
method: args.request?.method,
url: args.request?.url
});
const result = await next(args);
// Log response details if needed
console.log('Response metadata:', result.output?.$metadata);
return result;
},
{
name: "logRequestDetails",
step: "build"
}
);
const command = new GetCommand({
TableName: "test",
Key: { testKey: "aaa" },
// ReturnConsumedCapacity: "TOTAL",
});
const result = await ddbDocumentClient.send(command);
console.log(result);
console.log("Operation completed");
} catch (error) {
console.error("Error:", error);
}
const response = {
statusCode: 200,
body: JSON.stringify('Hello from Lambda!'),
};
return response;
};
|
Could you please let us know what region you are using? |
We are using the const client = new DynamoDBClient({maxAttempts: 10});
this.docClient = DynamoDBDocumentClient.from(client); Then in the methods we simply pass in the ScanCommand with the relevant table parameters const data = await this.docClient.send(command); Hope this helps the investigation. |
Thanks for the fast response. I tried in Could you please share your lambda config with us? What architecture are you using? I was using |
Hey @verebes1 , Since we can't reproduce this error, we still want to see what the headers look like on your end, could you please follow the comment I posted previously and share the raw response with us, so that we can dive deeper to investigate. I understand that you mentioned that you didn't touch this header, but the raw response is what we need to investigate. Thanks! |
Hey @zshzbh , |
Hey @verebes1 , Since you mentioned that the code is interacting with the SDK under NDA, I'll ask the AWS cloud support engineer to create an internal ticket so that we can chat more internally.
The Cloud support engineer observed this issue during a call with you(your team). Sorry for the confusion. |
ref: D229522017 |
Checkboxes for prior research
Describe the bug
One of our services has been brought down because of a change in the AWS-SDK. We have been using the "@aws-sdk/client-dynamodb" to instantiate a client:
In the code we were creating a ScanCommand that was retrieving all ids of items from a given DB. This code has been functioning fine without any issue up until 13-March-2025 when there was an autoredeployment of the lambda that updates connection certificates (so no code changes) This has broke our lambdas completely and we started getting the following error.
After having a call with AWS Support and testing multiple solutions. The only solution that worked was to add the AWS SDK as a node-module to the lambda package and pin it down to an older version specifically:
Any version post that one creates the same issue
The error message seems to come from one of the aws-sdk dependencies. We have managed to pinpoint the exact line of code that fails with that error and it is the one which sends the scancommand using the docClient.
await this.docClient.send(command);
Regression Issue
SDK version number
@aws-sdk/client-dynamodb@3.767.0
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
20.x
Reproduction Steps
Just send a ScanCommand to the DB using the latest package version and a Node 20.x runtime.
I am happy to provide more context if needed but this would have to be on a private call with AWS Support
Observed Behavior
Expected Behavior
Retrieval of the item's ids from a Dynamo DB table
Possible Solution
Pin down the packages to these:
Additional Information/Context
No response
The text was updated successfully, but these errors were encountered: