diff --git a/test/versioned/aws-sdk-v3/bedrock-chat-completions.tap.js b/test/versioned/aws-sdk-v3/bedrock-chat-completions.tap.js index f2fb5a4427..c5491fe0e0 100644 --- a/test/versioned/aws-sdk-v3/bedrock-chat-completions.tap.js +++ b/test/versioned/aws-sdk-v3/bedrock-chat-completions.tap.js @@ -13,20 +13,16 @@ const createAiResponseServer = require('../../lib/aws-server-stubs/ai-server') const { FAKE_CREDENTIALS } = require('../../lib/aws-server-stubs') const { DESTINATIONS } = require('../../../lib/config/attribute-filter') -const pkgVersion = (function () { - try { - const { version } = require('@smithy/smithy-client/package.json') - return version - } catch { - try { - const { - version - } = require('./node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/smithy-client/package.json') - return version - } catch {} - } - /* eslint-disable-next-line */ -}()) +// The shim will utilize the version of `@smithy/smithy-client` that is required +// by the `@aws-sdk/client-bedrock-runtime` module to set the version string +// on metrics. So we want to require that specific version instead of the one +// in our dependency tree. We can't use `require.resolve('mod', { paths: [] })` +// here because that appends the paths to the lookup tree instead of prepending +// them. Thus, we will still occasionally resolve to the module in our tree +// instead of the one in the test suite's tree. +const { + version: pkgVersion +} = require('./node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/smithy-client/package.json') const requests = { ai21: (prompt, modelId) => ({