<p>I am using celery with a fastAPI.</p>
<p>Getting <strong>Can't decode message body: ContentDisallowed('Refusing to deserialize untrusted content of type json (application/json)')</strong> while running in docker. When running the same in local machine without docker there is not issue.</p>
<p>The configuration for the same is as below.</p>
<pre><code>celery_app = Celery('cda-celery-tasks',
                    broker=CFG.BROKER_URL,
                    backend=CFG.BACKEND_URL,
                    include=['src.tasks.tasks']
                    )

celery_app.conf.task_serializer = 'pickle'
celery_app.conf.result_serializer = 'pickle'
celery_app.conf.accept_content = ['pickle']
celery_app.conf.enable_utc = True

</code></pre>
<p>While Running in docker I am getting the error continuously</p>
<pre><code>FROM python:3.8
WORKDIR /app

COPY . .

RUN pip3 install poetry
ENV PATH=&quot;/root/.poetry/bin:$PATH&quot;

RUN poetry install
</code></pre>
<p>the celery is started using the following command from kubernetes.</p>
<p><code>poetry run celery -A src.infrastructure.celery_application worker --loglevel=INFO --concurrency 2</code></p>
<p>While running I am getting the error continuously</p>
<p>Can't decode message body: ContentDisallowed('Refusing to deserialize untrusted content of type json (application/json)')</p>
<pre><code>body: '{&quot;method&quot;: &quot;enable_events&quot;, &quot;arguments&quot;: {}, &quot;destination&quot;: null, &quot;pattern&quot;: null, &quot;matcher&quot;: null}' (99b)
Traceback (most recent call last):
  File &quot;/root/.cache/pypoetry/virtualenvs/cda-9TtSrW0h-py3.8/lib/python3.8/site-packages/kombu/messaging.py&quot;, line 620, in _receive_callback
    decoded = None if on_m else message.decode()
  File &quot;/root/.cache/pypoetry/virtualenvs/cda-9TtSrW0h-py3.8/lib/python3.8/site-packages/kombu/message.py&quot;, line 194, in decode
    self._decoded_cache = self._decode()
  File &quot;/root/.cache/pypoetry/virtualenvs/cda-9TtSrW0h-py3.8/lib/python3.8/site-packages/kombu/message.py&quot;, line 198, in _decode
    return loads(self.body, self.content_type,
  File &quot;/root/.cache/pypoetry/virtualenvs/cda-9TtSrW0h-py3.8/lib/python3.8/site-packages/kombu/serialization.py&quot;, line 242, in loads
    raise self._for_untrusted_content(content_type, 'untrusted')
kombu.exceptions.ContentDisallowed: Refusing to deserialize untrusted content of type json (application/json)
</code></pre>
<p>Could someone please tell me the possible cause and solution to manage the same? If I've missed anything, over- or under-emphasized a specific point, please let me know in the comments. Thank you so much in advance for your time.</p>

Nithin Varghese
<p>Configuring the celery_app with the accept_content  type seems to fix the issue:</p>
<pre><code>celery_app.conf.accept_content = ['application/json', 'application/x-python-serialize', 'pickle']

</code></pre>
