Ministack: Free, open-source local AWS emulator - 60+ services, Terraform compatible, real databases. Free forever. MIT licensed.
Python awsaws-emulatoraws-localaws-sdkdevtoolsdockerdynamodbec2emulatorlambdalocalstacklocalstack-alternativeministackmock-awsopen-sourcepythons3sqsterraform
fix(sns): accept object Message from stepfunctions on sns:publish (#960)
noy18b00c10b30f
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 0d6d582f..b4683acc 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -5,6 +5,13 @@ All notable changes to MiniStack will be documented here.Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).Versioning follows [Semantic Versioning](https://semver.org/).+## [Unreleased]++### Fixed+- **SNS — `Publish` now accepts non-string `Message` values** — Step Functions' `arn:aws:states:::sns:publish` integration does not always pass `Parameters.Message` as a plain string; inline object values (e.g. in YAML or ASL) arrive as structured data. MiniStack previously treated only strings as valid and publish failed on dict values. Non-string messages are now JSON-serialized before delivery.++---+## [1.3.65] — 2026-06-19### Fixeddiff --git a/ministack/services/sns.py b/ministack/services/sns.pyindex 804392dd..8b0ee93e 100644--- a/ministack/services/sns.py+++ b/ministack/services/sns.py@@ -538,6 +538,9 @@ def _publish(params):subject = _p(params, "Subject")message_structure = _p(params, "MessageStructure")+ if isinstance(message, dict):+ message = json.dumps(message)+if phone_number and not topic_arn:msg_id = new_uuid()logger.info("SNS SMS stub to %s: %s", phone_number, message[:80])diff --git a/tests/test_stepfunctions.py b/tests/test_stepfunctions.pyindex 8d453ac6..3de719d9 100644--- a/tests/test_stepfunctions.py+++ b/tests/test_stepfunctions.py@@ -1617,6 +1617,68 @@ def test_sfn_integration_sns_publish(sfn, sns):output = json.loads(desc["output"])assert "MessageId" in output++def test_sfn_integration_sns_publish_structured_payload(sfn, sns, sqs):+ """Task state publishes a structured Message object via arn:aws:states:::sns:publish."""+ topic = sns.create_topic(Name="sfn-integ-sns-json-payload")+ topic_arn = topic["TopicArn"]+ str1 = "string1"+ str2 = "string2"++ q_url = sqs.create_queue(QueueName="sfn-integ-sns-json-payload-q")["QueueUrl"]+ q_arn = sqs.get_queue_attributes(+ QueueUrl=q_url,+ AttributeNames=["QueueArn"],+ )["Attributes"]["QueueArn"]+ sns.subscribe(TopicArn=topic_arn, Protocol="sqs", Endpoint=q_arn)++ definition = json.dumps(+ {+ "StartAt": "Publish",+ "States": {+ "Publish": {+ "Type": "Task",+ "Resource": "arn:aws:states:::sns:publish",+ "Parameters": {+ "TopicArn": topic_arn,+ "Message": {+ "str1.$": "$.str1",+ "str2.$": "$.str2",+ },+ },+ "End": True,+ },+ },+ }+ )+ sm = sfn.create_state_machine(+ name="sfn-sns-json-payload",+ definition=definition,+ roleArn="arn:aws:iam::000000000000:role/R",+ )+ ex = sfn.start_execution(+ stateMachineArn=sm["stateMachineArn"],+ input=json.dumps({"str1": str1, "str2": str2}),+ )++ desc = _wait_sfn(sfn, ex["executionArn"])+ assert desc["status"] == "SUCCEEDED"+ output = json.loads(desc["output"])+ assert "MessageId" in output++ msgs = sqs.receive_message(+ QueueUrl=q_url,+ MaxNumberOfMessages=1,+ WaitTimeSeconds=1,+ )+ assert len(msgs.get("Messages", [])) == 1+ envelope = json.loads(msgs["Messages"][0]["Body"])+ assert json.loads(envelope["Message"]) == {+ "str1": str1,+ "str2": str2,+ }++def test_sfn_integration_dynamodb_put_get(sfn, ddb):"""Task states write and read from DynamoDB."""table_name = "sfn-integ-ddb-test"