Skip to content

client-lambda UpdateAliasCommand throws an InternalError #7254

@athielke

Description

@athielke

Checkboxes for prior research

Describe the bug

When attempting to update a lambda alias with weighted routing config, the SDK throws an InternalError:

// Publish version 1 of the lambda

// Create an initial alias pointing to version 1
await lambdaClient.send(
  new CreateAliasCommand({
    FunctionName: "my-test-function",
    Name: "active",
    FunctionVersion: "1",
  }),
);

// Publish version 2 of the lambda

// Attempt to update the alias to point to version 2 and 1
await lambdaClient.send(
  new UpdateAliasCommand({
    FunctionName: "my-test-function",
    FunctionVersion: "2",
    Name: "active",
    RoutingConfig: {
      AdditionalVersionWeights: {
        1: 0.95,
      },
    },
  }),
);

The lambdaClient.send at the end throws:

exception while calling lambda.UpdateAlias: LambdaProvider._create_routing_config_model() missing 1 required positional argument: 'function_version'
InternalError: exception while calling lambda.UpdateAlias: LambdaProvider._create_routing_config_model() missing 1 required positional argument: 'function_version'
    at throwDefaultError (/Users/--user--/sample-service/node_modules/@smithy/smithy-client/dist-cjs/index.js:388:20)
    at /Users/--user--/sample-service/node_modules/@smithy/smithy-client/dist-cjs/index.js:397:5
    at de_CommandError (/Users/--user--/sample-service/node_modules/@aws-sdk/client-lambda/dist-cjs/index.js:4079:14)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
    at /Users/--user--/sample-service/node_modules/@smithy/middleware-serde/dist-cjs/index.js:36:20
    at /Users/--user--/sample-service/node_modules/@smithy/core/dist-cjs/index.js:193:18
    at /Users/--user--/sample-service/node_modules/@smithy/middleware-retry/dist-cjs/index.js:320:38
    at /Users/--user--/sample-service/node_modules/@aws-sdk/client-lambda/node_modules/@aws-sdk/middleware-logger/dist-cjs/index.js:33:22
    at Object.<anonymous> (/Users/--user--/sample-service/tests/alias.test.js:150:23)

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

v24.4.1

Reproduction Steps

Start a localstack container and configure lambdaClient, then deploy a function, create an alias, update the function, and attempt to update the alias:

// Publish version 1 of the lambda
await lambdaClient.send(
  new CreateFunctionCommand({
    FunctionName: "my-test-function",
    Runtime: "nodejs22.x",
    Role: "arn:aws:iam::000000000000:role/lambda-role",
    Handler: "index.handler",
    Code: {
      ZipFile: readFileSync("tests/function.zip"),
    },
    Timeout: 30,
    MemorySize: 128,
    Publish: true,
  }),
);

// Wait for the lambda to be active

// Create an initial alias pointing to version 1
await lambdaClient.send(
  new CreateAliasCommand({
    FunctionName: "my-test-function",
    Name: "active",
    FunctionVersion: "1",
  }),
);

// Publish version 2 of the lambda
await lambdaClient.send(
  new UpdateFunctionCodeCommand({
    FunctionName: "my-test-function",
    ZipFile: readFileSync("tests/function-updated.zip"),
    Publish: true,
  }),
);

// Wait for the update to be successful

// Attempt to update the alias to point to version 2 and 1
await lambdaClient.send(
  new UpdateAliasCommand({
    FunctionName: "my-test-function",
    FunctionVersion: "2",
    Name: "active",
    RoutingConfig: {
      AdditionalVersionWeights: {
        1: 0.95,
      },
    },
  }),
);

Observed Behavior

The UpdateAliasCommand fails with an InternalError:

exception while calling lambda.UpdateAlias: LambdaProvider._create_routing_config_model() missing 1 required positional argument: 'function_version'
InternalError: exception while calling lambda.UpdateAlias: LambdaProvider._create_routing_config_model() missing 1 required positional argument: 'function_version'
    at throwDefaultError (/Users/--user--/sample-service/node_modules/@smithy/smithy-client/dist-cjs/index.js:388:20)
    at /Users/--user--/sample-service/node_modules/@smithy/smithy-client/dist-cjs/index.js:397:5
    at de_CommandError (/Users/--user--/sample-service/node_modules/@aws-sdk/client-lambda/dist-cjs/index.js:4079:14)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
    at /Users/--user--/sample-service/node_modules/@smithy/middleware-serde/dist-cjs/index.js:36:20
    at /Users/--user--/sample-service/node_modules/@smithy/core/dist-cjs/index.js:193:18
    at /Users/--user--/sample-service/node_modules/@smithy/middleware-retry/dist-cjs/index.js:320:38
    at /Users/--user--/sample-service/node_modules/@aws-sdk/client-lambda/node_modules/@aws-sdk/middleware-logger/dist-cjs/index.js:33:22
    at Object.<anonymous> (/Users/--user--/sample-service/tests/alias.test.js:150:23)

Expected Behavior

The lambda alias is updated with the weighted routing config.

Possible Solution

No response

Additional Information/Context

No response

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.p2This is a standard priority issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions