core: Remote files are no longer supported in Slack notifications

The problem

After release v0.107.7, any time i try and invoke an automation that attempts to post an image to a slack channel (in my case a CCTV line crossing event that normally logs into the camera to get a still image, which it then posts to the slack channel post), the automation fails to run, and the logs show the below Type Cast problem.

Environment

  • Home Assistant Core release with the issue: I have walked back version by version (i have a docker-based install) to pinpoint v0.107.7 still works - anything after that is broken.
  • Last working Home Assistant Core release (if known): v0.107.7
  • Operating environment (Home Assistant/Supervised/Docker/venv): Docker (on ubuntu host)
  • Integration causing this issue: Slack
  • Link to integration documentation on our website:

Problem-relevant configuration.yaml

    - service: notify.k_slack_push
      data:
        message: '_[motion]_ *PORCH-CAM:* line crossing detected'
        target: ['#perimeter']
        # THE BELOW data/file/url chunk (i.e. attaching images!) is BROKEN AFTER v0.107.7 (and still in v0.112.x)...."TypeError: expected str, bytes or os.PathLike object, not collections.OrderedDict"
        data: 
          file:
            url: "http://1.1.1.1:80/ISAPI/Streaming/channels/1/picture"   
            username: 'admin'
            password: !secret k_fringelevelpass
            auth: digest

Traceback/Error logs

        2020-06-20 11:46:37 ERROR (MainThread) [homeassistant.components.automation] CCTV: Porch Line Crossing: Error executing script. Unexpected error for call_service at pos 1: expected str, bytes or os.PathLike object, not collections.OrderedDict
        Traceback (most recent call last):
          File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 153, in _async_step
            self, f"_async_{cv.determine_script_action(self._action)}_step"
          File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 656, in _async_call_service_step
            *self._prep_call_service_step(), blocking=True, context=self._context
          File "/usr/src/homeassistant/homeassistant/core.py", line 1260, in async_call
            task.result()
          File "/usr/src/homeassistant/homeassistant/core.py", line 1295, in _execute_service
            await handler.func(service_call)
          File "/usr/src/homeassistant/homeassistant/components/notify/__init__.py", line 119, in async_notify_message
            await notify_service.async_send_message(**kwargs)
          File "/usr/src/homeassistant/homeassistant/components/slack/notify.py", line 151, in async_send_message
            data[ATTR_FILE], targets, message, title
          File "/usr/src/homeassistant/homeassistant/components/slack/notify.py", line 97, in _async_send_local_file_message
            if not self._hass.config.is_allowed_path(path):
          File "/usr/src/homeassistant/homeassistant/core.py", line 1360, in is_allowed_path
            thepath = pathlib.Path(path)
          File "/usr/local/lib/python3.7/pathlib.py", line 1022, in __new__
            self = cls._from_parts(args, init=False)
          File "/usr/local/lib/python3.7/pathlib.py", line 669, in _from_parts
            drv, root, parts = self._parse_args(args)
          File "/usr/local/lib/python3.7/pathlib.py", line 653, in _parse_args
            a = os.fspath(a)
        TypeError: expected str, bytes or os.PathLike object, not collections.OrderedDict

Additional information

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17 (7 by maintainers)

Most upvoted comments

@keiranharris You are correct!

Marking this with the waiting-for-upstream label, as we’re somewhat powerless until the upstream library supports this (by, say, using httpx instead of aiohttp).

Probably makes sense not to have this auto-close. I think a solution still needs to be found.

Great to hear, @keiranharris! I’m still not seeing a clean way to get Digest Auth in here just yet, so I’ll keep this issue open and continue to 🤞 that we see an upstream solution in aiohttp.

Thanks @bachya really appreciate this. Dont bust yourself though - i have a workaround that involves hooking the image through the filesystem in a two step process (snapshot, then upload). Digest would be cleaner but im back in the game again at least. Thanks again. image

Thanks for the heads up, @keiranharris. I was afraid of this – from https://github.com/home-assistant/core/pull/37161:

Note that while #33287 offered support for remote files using Basic Auth and Digest Auth, this PR only adds support for Basic Auth because aiohttp has yet to implement a Digest Auth helper.

So, I need to start hunting for for a Digest Auth solution. I’ll re-open this issue while I investigate.

Done. Closing the loop here on this thread. Architecture issue #404. Thanks for the background and guidance on this @bachya

Gotcha. Ok thanks will do. Thanks for the rapid comms on this.