Skip to content

bug: StepFunction throwing InvalidDefinition for "Version" MessageAttribute #12186

@Travis-Kirton

Description

@Travis-Kirton

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Creating a StepFunction and it seems if you use a MessageAttribute with the key of Version, the step function fails.

State machine JSON

{
  "StartAt": "Delay",
  "Comment": "Publish to SNS with delay",
  "States": {
    "Delay": {
      "Type": "Wait",
      "Seconds": 5,
      "Next": "Publish to SNS"
    },
    "Publish to SNS": {
      "Type": "Task",
      "Resource": "arn:aws:states:::sns:publish",
      "Parameters": {
        "TopicArn": "${var.offer_sfn_sns_topic_arn}",
        "Message.$": "$.message",
        "MessageAttributes": {
          "Version": {
            "DataType": "String",
            "StringValue": "Hello World"
          }
        }
      },
      "End": true
    }
  }
}

Command

awslocal stepfunctions create-state-machine --name "test" \
      --role-arn "arn:aws:iam::000000000000:role/step_function_role" \
      --definition file://sfn_definition.json \
      --type STANDARD

Output

An error occurred (InvalidDefinition) when calling the CreateStateMachine operation: ASLParserException ['line 17:10, at "Version", no viable alternative at input \'{"Version"\'', 'line 23:6, at "End", mismatched input \'"End"\' expecting {\'"Comment"\', \'"States"\', \'"StartAt"\', \'"Version"\', \'"TimeoutSeconds"\', \'"QueryLanguage"\'}', "line 25:2, at }, mismatched input '}' expecting <EOF>"]

When I change Version to Version1 or even lowercase version, the StepFunction is created

{
    "stateMachineArn": "arn:aws:states:us-west-2:000000000000:stateMachine:test",
    "creationDate": "2025-01-25T17:43:17.180425+00:00"
}

Expected Behavior

Expected behaviour is that there are no reserved MessageAttribute names and Version is allowed to be used.

How are you starting LocalStack?

Running localstack (4.0.3) via docker-compose

localstack_main:
    container_name: "${LOCALSTACK_DOCKER_NAME:-localstack-main}"
    image: localstack/localstack:4.0.3
    ports:
      - 4566:4566            # LocalStack Gateway
      - 4510-4559:4510-4559  # external services port range
    environment:
      - SERVICES=apigateway,cloudwatch,ec2,iam,lambda,logs,s3,sns,sqs,stepfunctions,sts,events
      - DEBUG=${DEBUG:-0}
      - DD_TRACE_ENABLED=false
    volumes:
      - "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack"
      - "/var/run/docker.sock:/var/run/docker.sock"

With a docker-compose file

Steps To Reproduce

  1. Create JSON definition file with following contents
{
  "StartAt": "Delay",
  "Comment": "Publish to SNS with delay",
  "States": {
    "Delay": {
      "Type": "Wait",
      "Seconds": 5,
      "Next": "Publish to SNS"
    },
    "Publish to SNS": {
      "Type": "Task",
      "Resource": "arn:aws:states:::sns:publish",
      "Parameters": {
        "TopicArn": "${var.offer_sfn_sns_topic_arn}",
        "Message.$": "$.message",
        "MessageAttributes": {
          "Version": {
            "DataType": "String",
            "StringValue": "Hello World"
          }
        }
      },
      "End": true
    }
  }
}
  1. Run following awslocal command:
awslocal stepfunctions create-state-machine --name "test" \
      --role-arn "arn:aws:iam::000000000000:role/step_function_role" \
      --definition file://sfn_definition.json \
      --type STANDARD

Environment

- OS:macOS Sequoia 15.2
- LocalStack:
  LocalStack version: 4.0.3
  LocalStack Docker image sha: sha256:17c2f79ca4e1f804eb912291a19713d4134806325ef0d21d4c1053161dfa72d0
  LocalStack build date: 2024-11-29
  LocalStack build git hash: aa795ed1c

Anything else?

No response

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions