-
Notifications
You must be signed in to change notification settings - Fork 634
Description
Checkboxes for prior research
- I've gone through Developer Guide and API reference
- I've checked AWS Forums and StackOverflow.
- I've searched for previous similar issues and didn't find any solution.
Describe the bug
A change in 3.667, PR #6546 , accidentally changed behaviour of the credential provider. This change is now in the lambda runner in US-East-1, causing production issues for users not bundling the SDK, or for users that bundle version 3.667 or later.
This line invokes the customer-supplied credential provider, but does not pass through the credential arguments, causing any arguments supplied by the user to be dropped.
A fix for the issue is to pass through the parameters.
A specific parameter that gets dropped in my case is the forceRefresh
parameter, which is used in a more complex scenario to provide tenant-scoped credentials.
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
v22.13.0
Reproduction Steps
Minimal reproduction which passes in 3.666 and fails in 3.667 (and later)
import { DynamoDBClient, ListTablesCommand } from "@aws-sdk/client-dynamodb";
import { assert } from "console";
let client = null;
async function getClient() {
if (!client) {
client = new DynamoDBClient({
credentials: credentialsProvider(),
region: "us-east-1",
});
}
await client.config.credentials({ forceRefresh: true });
return client;
}
let counter = 0;
function credentialsProvider() {
return async function () {
counter += 1;
console.log("Getting credentials");
return {
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
sessionToken: process.env.AWS_SESSION_TOKEN,
expiration: new Date(Date.now() + 3600 * 1000), // 1 hour
};
};
}
for (let i = 0; i < 2; i++) {
let client = await getClient();
console.log(`Got Client: ${i + 1}`);
client.send(new ListTablesCommand({}));
console.log(`Got result: ${i + 1}`);
}
assert(counter === 2, "Counter should be 2");
package.json
{
"name": "aws-sdk-regression",
"version": "1.0.0",
"description": "",
"main": "index.js",
"keywords": [],
"author": "",
"license": "ISC",
"type": "module",
"dependencies": {
"@aws-sdk/client-dynamodb": "3.667",
"@aws-sdk/types": "3.664"
},
"devDependencies": {
"@types/node": "^22.13.11"
},
"pnpm": {
"overrides": {
"@aws-sdk/core": "3.666"
}
}
}
Observed Behavior
Credentials fetched once
Expected Behavior
Credentials fetched twice
Possible Solution
credentials: isUserSupplied
? async (...parameters/*<-- added parameters param*/) =>
normalizedCreds!(...parameters/* <-- added parameters param*/).then((creds: AttributedAwsCredentialIdentity) =>
setCredentialFeature(creds, "CREDENTIALS_CODE", "e")
)
: normalizedCreds!,
Additional Information/Context
The PR that introduced this change was a chore PR to introduce logging, I believe the change was inadvertent.