aws-serverless-ecommerce-platform icon indicating copy to clipboard operation
aws-serverless-ecommerce-platform copied to clipboard

bug: error in payment-onCreatedFunction during payment integration tests

Open jeromevdl opened this issue 5 years ago • 0 comments

When deploying payment module (make all-payment), there is an error in cloudwatch logs for the payment-onCreatedFunction:

[ERROR] KeyError: 'paymentToken'
Traceback (most recent call last):
  File "/var/task/main.py", line 43, in handler
    payment_token = event["detail"]["paymentToken"]

Looking at the event, we have an OrderCreated event, mixed with a PACKAGING_FAILED status and actually no paymentToken:

{
    "timestamp": "2020-07-09 10:06:19,766",
    "level": "INFO",
    "location": "decorate:195",
    "service": "payment",
    "sampling_rate": 0,
    "cold_start": true,
    "function_name": "ecommerce-dev-payment-OnCreatedFunction-BN6M5X4Z0GYQ",
    "function_memory_size": "128",
    "function_arn": "arn:aws:lambda:eu-central-1:123456789012:function:ecommerce-dev-payment-OnCreatedFunction-BN6M5X4Z0GYQ",
    "function_request_id": "b5dd8fa9-e285-4230-b8ae-eeb4f3b1a270",
    "message": {
        "version": "0",
        "id": "c26030dc-e054-66df-b6f9-8cf149512e74",
        "detail-type": "OrderCreated",
        "source": "ecommerce.orders",
        "account": "123456789012",
        "time": "2020-07-09T10:06:19Z",
        "region": "eu-central-1",
        "resources": [
            "ceccfd49-fc01-4f07-b8f0-73289c0fed34"
        ],
        "detail": {
            "orderId": "ceccfd49-fc01-4f07-b8f0-73289c0fed34",
            "status": "PACKAGING_FAILED"
        }
    }
}

The problem comes from the integration test (test_on_failed_warehouse): https://github.com/aws-samples/aws-serverless-ecommerce-platform/blob/969f6f89a7e2071f28a9f6c728fc7d6dc8adfd2f/payment/tests/integ/test_on_events.py#L147

Same error and quite similar event for the test_on_failed_delivery: https://github.com/aws-samples/aws-serverless-ecommerce-platform/blob/969f6f89a7e2071f28a9f6c728fc7d6dc8adfd2f/payment/tests/integ/test_on_events.py#L204

{
    "timestamp": "2020-07-09 13:15:13,939",
    "level": "INFO",
    "location": "decorate:195",
    "service": "payment",
    "sampling_rate": 0,
    "cold_start": false,
    "function_name": "ecommerce-dev-payment-OnCreatedFunction-BN6M5X4Z0GYQ",
    "function_memory_size": "128",
    "function_arn": "arn:aws:lambda:eu-central-1:123456789012:function:ecommerce-dev-payment-OnCreatedFunction-BN6M5X4Z0GYQ",
    "function_request_id": "f80301b8-0d87-4234-a38b-eaeec59c2dd1",
    "message": {
        "version": "0",
        "id": "a26a48d1-fc78-e935-50ab-1264c20467ea",
        "detail-type": "OrderCreated",
        "source": "ecommerce.orders",
        "account": "123456789012",
        "time": "2020-07-09T13:14:15Z",
        "region": "eu-central-1",
        "resources": [
            "b37284fe-ce16-4db8-a09c-349d08b539bb"
        ],
        "detail": {
            "orderId": "b37284fe-ce16-4db8-a09c-349d08b539bb",
            "status": "DELIVERY_FAILED"
        }
    }
}

jeromevdl avatar Jul 09 '20 13:07 jeromevdl