fix: resolve crash on all commands due to missing @aws-sdk/region-config-resolver#1276
Conversation
@aws-cdk/toolkit-lib's bundled CJS requires @aws-sdk/region-config-resolver, but @aws-sdk/client-sts@3.1048.0 dropped it as a dependency. Adding it as a direct dep ensures it's always available in node_modules. Also adds early --version interception in the entrypoint to avoid loading heavy dependencies for a simple version check. Constraint: Cannot pin @aws-cdk/toolkit-lib's transitive SDK versions Rejected: Pin client-sts to <3.1048.0 | would block all SDK updates Confidence: high Scope-risk: narrow
Package TarballHow to installnpm install https://github.com/aws/agentcore-cli/releases/download/pr-1276-tarball/aws-agentcore-0.13.1.tgz |
agentcore-cli-automation
left a comment
There was a problem hiding this comment.
LGTM. The fix is small and correct: pulling @aws-sdk/region-config-resolver up to a direct dependency of @aws/agentcore ensures npm hoists it into top-level node_modules, where toolkit-lib's bundled CJS require('@aws-sdk/region-config-resolver') will resolve it after @aws-sdk/client-sts@3.1048.0 dropped it as a transitive dep.
I verified the root cause against the npm registry: @aws-sdk/client-sts@3.1047.0 lists @aws-sdk/region-config-resolver as a dependency, but 3.1048.0 (current latest) does not, while @aws-cdk/toolkit-lib's bundle still requires it.
Nice that the early --version short-circuit was dropped in 3b66758 — since src/cli/index.ts statically imports ./cli.js (which imports @aws-cdk/toolkit-lib transitively via cdk/toolkit-lib/wrapper.ts), ESM hoisting + esbuild bundling means those imports are evaluated before any top-level statement runs, so the short-circuit couldn't actually have avoided loading the heavy deps. Glad that's gone.
Two minor things worth mentioning (non-blocking, your call):
- The PR description still mentions the early
--versioninterception that was removed — might be worth updating before merge so the commit history reflects what actually shipped. - This is effectively a workaround for an upstream issue (toolkit-lib's bundle not declaring
region-config-resolveras a direct dep). A short comment inpackage.jsonor a tracking issue link would help future maintainers know when it's safe to remove this direct dep.
Coverage Report
|
Summary
@aws-cdk/toolkit-lib@1.25.2depends on@aws-sdk/client-sts@^3, which now resolves to3.1048.0. That version removed@aws-sdk/region-config-resolverfrom its dependencies, buttoolkit-lib's bundled CJS still requires it — causing everyagentcorecommand to crash on fresh install.@aws-sdk/region-config-resolveras a direct dependency so it's always available.--versioninterception in the entrypoint to avoid loading heavy deps for version checks.Test plan
npm install -g .thenagentcore --versionprints version without erroragentcore status --helploads without crashnpm testpasses