Open ebeseda opened 5 years ago
Have you set the result_serializer
setting to use your serializer?
I'm guessing you didn't :).
@thedrow I did. It's in the code snippet above (settings.py)
Can you tell what's the content of the message?
b'{"body":"base64_sensitive_data_here=", "content-encoding": "utf-8", "content-type": "application/json", "headers": {"lang": "py", "task": "backend.tasks.restaurant.push_restaurant", "id": "7774f2c5-b527-4ebe-9985-22de48ee8c4f", "shadow": null, "eta": null, "expires": null, "group": null, "retries": 0, "timelimit": [null, null], "root_id": "7774f2c5-b527-4ebe-9985-22de48ee8c4f", "parent_id": null, "argsrepr": "(\'tb\', \'33615\')", "kwargsrepr": "{}", "origin": "gen11@de-ae-7dc8f985b-8bbmg", "__celery_context_data__": {"email": "some_email@gmail.com", "meta_request_id": "16397099-ca80-433d-8db9-afdc37ad291d", "meta_trace_id": "16397099-ca80-433d-8db9-afdc37ad291d", "platform": "tb"}}, "properties": {"correlation_id": "7774f2c5-b527-4ebe-9985-22de48ee8c4f", "reply_to": "5ef392bb-bb14-3247-9471-95923cb94226", "delivery_mode": 2, "delivery_info": {"exchange": "", "routing_key": "celery"}, "priority": 0, "body_encoding": "base64", "delivery_tag": "ab54832d-3696-499a-b012-b716e5f978ad"}}'
# body decode
b'[["tb", "33615"], {}, {"callbacks": null, "errbacks": null, "chain": null, "chord": null}]'
Somehow it puts JSON in the SQS.
Yes. That's why https://github.com/celery/kombu/commit/7ed7df0ca1acd5ec1cfe0d988a0a8a86291af50e#diff-3cc1ff6df0f488077057a603b8f5e5d4 was committed. Not all SQS messages are base64 encoded. I don't know why though.
Oh, AWS serializes some messages it generates using JSON. See https://github.com/celery/kombu/pull/937#issue-225587076. Could that be the issue?
@thedrow
In my case the whole SQS message is base64
encoded.
I decoded it and then decoded a message body before posting it here.
Do the message headers indicate that it is JSON somehow?
yes. "content-type": "application/json"
FYI
CELERY_ACCEPT_CONTENT = [MSGPACK_ENCODER_NAME, "json"]
helps me to not get a ContentDisallowed
error but still, the issue persists.
Hi, I've created my custom msgpack serializer and deserializer for kombu and successfully registered it:
It works as expected but sometimes I'm getting an error:
kombu.exceptions.ContentDisallowed: Refusing to deserialize untrusted content of type json (application/json)
Full traceback:
I have no idea why it happens. Somehow kombu puts a JSON to SQS In rare cases.
Env: celery 4.3.0 kombu 4.6.3
UPD: Added more error logging and got this traceback: