-
Notifications
You must be signed in to change notification settings - Fork 586
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
SDK errors with latest Bedrock clients import_client.setCredentialFeature and util_endpoints_2.EndpointCache is not a constructor #6716
Comments
Hi @abhirpat , I'm able to import it just fine: Are you sure you are using the latest version? What happens if you run this command?
Thanks, |
I get a similar error in AWS SDK for JavaScript V3 @aws-sdk/[email protected]
|
I can import this command as well. Same question to you: What happens if you run this command?
Thanks, |
@RanVaknin While I resolved the initial dependency issue, upgrading to "@aws-sdk/client-bedrock-runtime": "^3.706.0" from 3.616.0 has introduced new compatibility problems. These errors could be due to the newer version conflicts with other AWS SDK clients (version 3.5XX.0 or 3.6XX.0) that are present in the Lambda function or layers. After reverting 3.706.0 to 3.616.0 fixes it. Could you please help investigate the source code to identify what's causing these issues? These version conflicts between AWS SDK packages are making maintenance difficult, as even minor version upgrade on one single package can lead to breaking changes and require upgrade of other packages.
|
Hi @abhirpat, This seems to be related to general issue of dependency management rather than an SDK related issue. You need to make sure to update all of your Thanks, |
@RanVaknin Thank you for your response. As I mentioned earlier, this has been my observation as well. I wanted to ask if it would be possible to make this is a feature request to the SDK team to minimize transitive dependencies that sdk client use. This would help reduce dependency conflicts or innovate other way to improve isolation between different clients. The main challenge we’re facing is that adding a new command to one client currently requires upgrading all SDK clients in the same code package for Lambda/layers. Increasing isolation could make these sdk dependencies more manageable. Would this be something the team might consider? Also, is there a documentation you recommend on best practices with sdk v3 dependency management? |
Hi @abhirpat, What you are suggesting is not feasible and would require rebuilding the SDK from the ground up. There are core dependencies that we have to supply to each SDK client because each client is designed to be its own standalone module. We have this existing Feature request. The existing feature request proposes using caret ranges for versioning to help manage minor updates and reduce conflicts. However, it doesn't fully eliminate the need for managing dependencies. While this method can help manage some conflicts by ensuring more consistent updates, developers must still monitor and adjust their setups to avoid issues from these shared dependencies. If you think that feature request is helpful, feel free to give it a thumbs up as it helps with prioritization. Since what you are asking for is not possible, I suggest we focus on unblocking you for now. Are you able to mitigate the errors you are getting by making sure all the minor versions aligned to the Thanks, |
Hi @RanVaknin I upgraded all other SDK dependences to latest but now they are throwing error. Here is error from client-comprehend @aws-sdk/client-comprehend": "3.699.0"
|
Hi @abhirpat, Seems like there is still a dependency issue. How are you running your code? Are you running it locally from a node js env? or deploying it somewhere like Lambda or docker? You have a few options to identify where the discrepancies come from.
Another option is to let NPM dedupe those dependencies for you by running I'm not sure why you are running into this issue consistently, it might be due to a outdated lock file, or something in your infrastructure that is impacting how dependencies are resolved. Without knowing your setup it will be difficult to diagnose. Thanks, |
Hi @RanVaknin it is deployed in the lambda and different layers. It is open source here. Before every build deployed, the node modules are removed and re-packaged. Could you please elucidate on your previous initial line of thought "there is still a dependency issue"? |
Hi @abhirpat , What I meant by "there is still a dependency issue" is that the SDK is working fine, I'm able to import the aforementioned packages without seeing this error which leads me to believe that the lambda layers is where this issue is manifesting. From provided repo code:
You clearly have multiple SDK clients set to different versions. Can you please update them all to the SAME latest version (today we are on 3.705.0) and see if it solves your issue? Thanks, |
@RanVaknin Yes, I already have upgraded to all the versions. You can ignore that file. That's not showing you development I was talking about because it is a previous release. It was for your reference which dependencies are involved. |
Hi @abhirpat , There must be an issue with the packaging step then. I'm able to create a NodeJS lambda with a layer bundling Bedrock runtime client and comprehend and run a comprehend command and I'm not seeing the error you were running into: import { readdir, readFile } from 'fs/promises';
import { join } from 'path';
import { ComprehendClient, ListEndpointsCommand } from '@aws-sdk/client-comprehend';
export const handler = async () => {
try {
const sdkPath = '/opt/nodejs/node_modules/@aws-sdk';
const modules = await readdir(sdkPath);
const versions = {};
for (const mod of modules) {
const pkg = await readFile(join(sdkPath, mod, 'package.json'), 'utf8');
versions[mod] = JSON.parse(pkg).version;
}
const client = new ComprehendClient();
const response = await client.send(new ListEndpointsCommand({}));
return {
statusCode: 200,
body: { versions, response }
};
} catch (err) {
console.log('Error:', err);
return { error: err.message };
}
}; results in: {
"statusCode": 200,
"body": {
"versions": {
"client-bedrock-runtime": "3.709.0",
"client-sso": "3.709.0",
"client-sso-oidc": "3.709.0",
"client-sts": "3.709.0",
"core": "3.709.0",
"credential-provider-env": "3.709.0",
"credential-provider-http": "3.709.0",
"credential-provider-ini": "3.709.0",
"credential-provider-node": "3.709.0",
"credential-provider-process": "3.709.0",
"credential-provider-sso": "3.709.0",
"credential-provider-web-identity": "3.709.0",
"middleware-host-header": "3.709.0",
"middleware-logger": "3.709.0",
"middleware-recursion-detection": "3.709.0",
"middleware-user-agent": "3.709.0",
"region-config-resolver": "3.709.0",
"token-providers": "3.709.0",
"types": "3.709.0",
"util-endpoints": "3.709.0",
"util-locate-window": "3.693.0",
"util-user-agent-browser": "3.709.0",
"util-user-agent-node": "3.709.0"
},
"response": {
"$metadata": {
"httpStatusCode": 200,
"requestId": "REDACTED",
"attempts": 1,
"totalRetryDelay": 0
},
"EndpointPropertiesList": []
}
}
} You can use this snippet to print out the various versions your layer is using. If you see a mismatch, its probably an issue with how you bundle your layer. You can try: $(DST): $(RESOURCES)
echo "Building $(NAME)";
rm -r ./nodejs || true
rm -r ./node_modules || true
npm install -production
+ npm dedupe
mkdir ./nodejs
mv node_modules ./nodejs/node_modules
rm -r $(DST) || true
zip -r $(DST) . Thanks, |
Thanks @RanVaknin. With recent release of sdk, these issues resolved itself. We are good to close. |
Checkboxes for prior research
Describe the bug
The npm package documentation shows RetrieveAndGenerateStream is available but it throws Error: TypeError: RetrieveAndGenerateStreamCommand is not a constructor with latest version.
Regression Issue
SDK version number
@aws-sdk/client-bedrock-agent-runtime": "3.706.0"
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
v20.18.1
Reproduction Steps
To reproduce, try importing RetrieveAndGenerateStreamCommand and it's not available
Observed Behavior
Throws error
Expected Behavior
The command should be made available since it is documented in the package.
Possible Solution
No response
Additional Information/Context
No response
The text was updated successfully, but these errors were encountered: