diff --git a/rhodecode/integrations/types/slack.py b/rhodecode/integrations/types/slack.py --- a/rhodecode/integrations/types/slack.py +++ b/rhodecode/integrations/types/slack.py @@ -145,6 +145,10 @@ class SlackIntegrationType(IntegrationTy @async_task(ignore_result=True, base=RequestContextTask) def post_text_to_slack(settings, slack_data: SlackData): + # because JSON serialization, if we run async with celery, deserialize to SlackData + if isinstance(slack_data, dict): + slack_data = SlackData(**slack_data) + title = slack_data.title text = slack_data.text fields = slack_data.fields diff --git a/rhodecode/tests/lib/test_ext_json.py b/rhodecode/tests/lib/test_ext_json.py --- a/rhodecode/tests/lib/test_ext_json.py +++ b/rhodecode/tests/lib/test_ext_json.py @@ -1,4 +1,4 @@ - +import dataclasses # Copyright (C) 2010-2023 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify @@ -164,3 +164,15 @@ def test_lazy_translation_string(baseapp assert b'{"label":"hello"}' == ext_json.json.dumps(data) assert b'{"label2":"singular"}' == ext_json.json.dumps(data2) + + +def test_serialize_dataclass(): + + @dataclasses.dataclass + class ExampleStruct: + field_str: str + field_int: int + struct = ExampleStruct(field_int=1, field_str='hello') + raw_struct = b'{"field_str":"hello","field_int":1}' + assert raw_struct == ext_json.json.dumps(struct) + assert struct == ExampleStruct(**ext_json.json.loads(raw_struct))