Problems with slack sending files as of 2023.10

in 2023.9 (and long before), I’ve had the following working:

- id: '169515xxxxxx'
  alias: Shop Upload
  description: ''
  trigger:
  - platform: mqtt
    topic: security-cam/shop/#
  condition: []
  action:
  - delay:
      hours: 0
      minutes: 1
      seconds: 15
      milliseconds: 0
  - service: notify.xxxx
    data:
      message: Uploaded Video
      title: Motion below deck
      target: '#testing'
      data:
        file:
          path: /media/shop/recording_{{ trigger.payload }}.mp4

However since 2023.10.0 and .1 the “attachment” of a file in the message (i.e. notifications work, if I remove “data” from the notification")

yields the the following error:

2023-10-10 18:41:31.837 ERROR (MainThread) [homeassistant.components.automation.moss_video_snapshot_and_video_upload] Shop Video Snapshot and Video Upload: Parallel action at step 4: parallel 1: Error executing script. Unexpected error for call_service at pos 1: Can not serialize value type: <class 'NoneType'>
 headers: {}
 value: None
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 508, in update_body_from_data
    body = payload.PAYLOAD_REGISTRY.get(body, disposition=None)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/payload.py", line 118, in get
    raise LookupError()
aiohttp.payload.LookupError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/formdata.py", line 145, in _gen_form_data
    part = payload.get_payload(
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/payload.py", line 71, in get_payload
    return PAYLOAD_REGISTRY.get(data, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/payload.py", line 118, in get
    raise LookupError()
aiohttp.payload.LookupError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 468, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 704, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 666, in _async_run_long_action
    return long_task.result()
           ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2012, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2049, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/notify/legacy.py", line 264, in _async_notify_message_service
    await self.async_send_message(**kwargs)
  File "/usr/src/homeassistant/homeassistant/components/slack/notify.py", line 323, in async_send_message
    return await self._async_send_local_file_message(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/slack/notify.py", line 163, in _async_send_local_file_message
    await self._client.files_upload(
  File "/usr/local/lib/python3.11/site-packages/slack/web/base_client.py", line 213, in _send
    res = await self._request(
          ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/slack/web/base_client.py", line 244, in _request
    async with session.request(http_verb, api_url, **req_args) as res:
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 1141, in __aenter__
    self._resp = await self._coro
                 ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 508, in _request
    req = self._request_class(
          ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 313, in __init__
    self.update_body_from_data(data)
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 510, in update_body_from_data
    body = FormData(body)()
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/formdata.py", line 170, in __call__
    return self._gen_form_data()
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/formdata.py", line 149, in _gen_form_data
    raise TypeError(
TypeError: Can not serialize value type: <class 'NoneType'>
 headers: {}
 value: None

Uncertain if the slack api changed with the 2023.10, or something else?

If I downgrade back to 2023.9.3 all works well again.

I have the exact same fault.
Any updates on a solution?

At least I’m not completely crazy then :slight_smile:

When I put slack integration in debug…

it looks ALOT like:

I just put this in:

A feature recently added to the slack integration (support for slack replies) introduced the bug. It’s been fixed and should be in 2023.10.02.

My apologies for the hassle it’s created. Given the small nature of the fix you may have success applying the fix manually in the meantime. (I can’t speak to whether that’s a supported method for HA though)

2 Likes