Core: API utf-8 decode issue

Created on 17 Feb 2017  ·  30Comments  ·  Source: home-assistant/core

Make sure you are running the latest version of Home Assistant before reporting an issue.

You should only file an issue if you found a bug. Feature and enhancement requests should go in the Feature Requests section of our community forum:

Home Assistant release (hass --version):
0.38.3

Python release (python3 --version):

Component/platform:
api.py

Description of problem:
Using Plex WebHooks and the API is unable to handle the request payload

Expected:
API receives payload and passes to appropriate server

Problem-relevant configuration.yaml entries and steps to reproduce:

 plextest:
    alias: 'Webhook test'            
    sequence:
      - service: notify.notifyall
        data_template: 
          message: >
            '{{ Player.title }}'

  1. Set up webhook in plex (https://home.domain.com/api/services/script/plextest?api_password=PasswordGoesHere)
  2. start a video
  3. error occurs

Traceback (if applicable):

17-02-17 15:11:23 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/aiohttp/web_server.py", line 62, in handle_request
    resp = yield from self._handler(request)
  File "/usr/local/lib/python3.5/site-packages/aiohttp/web.py", line 270, in _handle
    resp = yield from handler(request)
  File "/usr/local/lib/python3.5/asyncio/coroutines.py", line 213, in coro
    res = yield from res
  File "/usr/local/lib/python3.5/asyncio/coroutines.py", line 213, in coro
    res = yield from res
  File "/usr/src/app/homeassistant/components/http/__init__.py", line 427, in handle
    result = yield from result
  File "/usr/src/app/homeassistant/components/api.py", line 311, in post
    body = yield from request.text()
  File "/usr/local/lib/python3.5/site-packages/aiohttp/web_reqrep.py", line 394, in text
    return bytes_body.decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 6270: invalid start byte
17-02-17 15:12:07 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/aiohttp/web_server.py", line 62, in handle_request
    resp = yield from self._handler(request)
  File "/usr/local/lib/python3.5/site-packages/aiohttp/web.py", line 270, in _handle
    resp = yield from handler(request)
  File "/usr/local/lib/python3.5/asyncio/coroutines.py", line 213, in coro
    res = yield from res
  File "/usr/local/lib/python3.5/asyncio/coroutines.py", line 213, in coro
    res = yield from res
  File "/usr/src/app/homeassistant/components/http/__init__.py", line 427, in handle
    result = yield from result
  File "/usr/src/app/homeassistant/components/api.py", line 312, in post
    data = json.loads(body) if body else None
  File "/usr/local/lib/python3.5/json/__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.5/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.5/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)


Additional info:

Works fine when using the dev-service to call the script using the request payload here: https://support.plex.tv/hc/en-us/articles/115002267687

waiting-for-reply

Most helpful comment

I would assume it's possible, it's a bonafide HTTP server. I'm not sure how _easy_ it is, but many HTTP stacks provide processing for multi-part POSTs.

(I'm from Plex, if it wasn't clear. Glad someone's using Webhooks!)

All 30 comments

The payload that leads to this error would be helpful here. You can use something like fiddler to catch those. Else reproducing this behavior might prove tricky as it requires a plex pass.

~Cheers

Okay. Here's the payload that I've outputted from tcpflow in Linux and I make it human-readable. Unsure if UUID is sensitive, so I've "x'd" them out.

{  
  "event":"media.play",
  "user":true,
  "owner":true,
  "Account":{  
    "id":1,
    "thumb":"https://plex.tv/users/fd6f05d106f45a73/avatar?c=2017-02-19+03%3A50%3A09+UTC",
    "title":"GraysonPeddie"
  },
  "Server":{  
    "title":"My SHIELD Android TV",
    "uuid":"xxxxxxxxxxxxxxxxx..."
  },
  "Player":{  
    "local":true,
    "publicAddress":"8.26.244.126",
    "title":"Nexus 7 (2012)",
    "uuid":"xxxxxxxxxxxxxxxxx..."
  },
  "Metadata":{  
    "librarySectionType":"show",
    "ratingKey":"12692",
    "key":"/library/metadata/12692",
    "parentRatingKey":"12691",
    "grandparentRatingKey":"12690",
    "guid":"com.plexapp.agents.thetvdb://95441/8/15?lang=en",
    "librarySectionID":4,
    "librarySectionKey":"/library/sections/4",
    "type":"episode",
    "title":"Payback",
    "grandparentKey":"/library/metadata/12690",
    "parentKey":"/library/metadata/12691",
    "grandparentTitle":"NCIS: Los Angeles",
    "parentTitle":"Season 8",
    "contentRating":"TV-14",
    "summary":"Emotions run high for the team as one agent is held in an unknown location and tortured by the mole, while another discovers he was betrayed by someone he least expected.",
    "index":15,
    "parentIndex":8,
    "year":2017,
    "thumb":"/library/metadata/12692/thumb/1487559639",
    "art":"/library/metadata/12690/art/1487559640",
    "parentThumb":"/library/metadata/12691/thumb/1487559640",
    "grandparentThumb":"/library/metadata/12690/thumb/1487559640",
    "grandparentArt":"/library/metadata/12690/art/1487559640",
    "grandparentTheme":"/library/metadata/12690/theme/1487559640",
    "duration":3600000,
    "originallyAvailableAt":"2017-02-19",
    "addedAt":1487559608,
    "updatedAt":1487559639,
    "Director":[  
      {  
        "id":3569,
        "filter":"director=3569",
        "tag":"Terrence OHara"
      }
    ],
    "Writer":[  
      {  
        "id":3568,
        "filter":"writer=3568",
        "tag":"Jordana Lewis Jaffe"
      }
    ]
  }
}

I just tried that payload and it worked fine. Any chance for getting the actual HTTP request that is causing an issue to reproduce?

~Cheers

Okay, what about this:

hass@home-server:~$ sudo tcpflow -i br0 port 8123 -c
tcpflow: listening on br0
192.168.000.017.60022-192.168.000.002.08123: POST /api/services/script/plex_webhook HTTP/1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36
Host: 192.168.0.2:8123
Accept: */*
Accept-Encoding: gzip
Content-Length: 10350
Content-Type: multipart/form-data; boundary=----------------------------5887e83586f4


192.168.000.017.60022-192.168.000.002.08123: ------------------------------5887e83586f4
Content-Disposition: form-data; name="payload"
Content-Type: application/json

{"event":"media.play","user":true,"owner":true,"Account":{"id":1,"thumb":"https://plex.tv/users/fd6f05d106f45a73/avatar?c=2017-02-20+03%3A08%3A28+UTC","title":"GraysonPeddie"},"Server":{"title":"My SHIELD Android TV","uuid":"..."},"Player":{"local":true,"publicAddress":"8.26.244.126","title":"Plex Web (Chrome)","uuid":"..."},"Metadata":{"librarySectionType":"show","ratingKey":"12692","key":"/library/metadata/12692","parentRatingKey":"12691","grandparentRatingKey":"12690","guid":"com.plexapp.agents.thetvdb://95441/8/15?lang=en","librarySectionID":4,"librarySectionKey":"/library/sections/4","type":"episode","title":"Payback","grandparentKey":"/library/metadata/12690","parentKey":"/library/metadata/12691","grandparentTitle":"NCIS: Los Angeles","parentTitle":"Season 8","contentRating":"TV-14","summary":"Emotions run high for the team as one agent is held in an unknown location and tortured by the mole, while another discovers he was betrayed by someone he least expected.","index":15,"parentIndex":8,"viewOffset":3344131,"lastViewedAt":1556978583,"year":2017,"thumb":"/library/metadata/12692/thumb/1487559639","art":"/library/metadata/12690/art/1487559640","parentThumb":"/library/metadata/12691/thumb/1487559640","grandparentThumb":"/library/metadata/
192.168.000.017.60022-192.168.000.002.08123: 12690/thumb/1487559640","grandparentArt":"/library/metadata/12690/art/1487559640","grandparentTheme":"/library/metadata/12690/theme/1487559640","duration":3600000,"originallyAvailableAt":"2017-02-19","addedAt":1487559608,"updatedAt":1487559639,"Director":[{"id":3569,"filter":"director=3569","tag":"Terrence OHara"}],"Writer":[{"id":3568,"filter":"writer=3568","tag":"Jordana Lewis Jaffe"}]}}
------------------------------5887e83586f4
Content-Disposition: form-data; name="thumb"; filename="thumb.jpg"
Content-Type: image/jpeg

JFIFHHC
2!!22222222222222222222222222222222222222222222222222=!1"AQaq2#B$R3r%4CSb%!1A"Q2aq?BZIJ,t#a!NtD/JJ$XXhI8BG0UMn%q6.{,]1.gDj2  yFlR>i/+*)ck+ h]#+BG|nI([s#(VP.S,:m:(EBGb/JJ$X(Xhaal$D"i\
}-T| ?Go}e#.dgE-BjZ6FAiPoJMoVH4Fs(W{7;E1n/X"9m [email protected]"{!^a =+F4kn0CPD`N/gK8F#Uzz"0E
P]3 B<z<oD:Q2@airs,d4#[@a<OT,;5vDoj$gw,Nj~X7<!nOKipy(-tMfy!B2&s'qU6u^B@)juS&1ma)zz
)Fo}6ov#]8%nDJu4D-bQh@8'8*
V[X$K4]u^_cMxQeheKn`
v#@)sfu6}7$T2kKB;n@1M,oDIQi
E9s65LNka.s=,uaUb\v*2!nXU>P4,Y**\14["FN'{YC;?De]Z~U3"?2bv6-z=R66cb.|(]ST+M Fo_LaJEd.Q^l{db6['H(QT
W*[wjQ1*1)F#I_h}.6y/F]H xVW$9Q|::w:)mM:qoE~Ew;aI7
.46o>~N>-c,I]v2De>QQVUr,bZ
$E]3MkpDG$KzoR9(wnL|3s^Io !b?zr0PX<,#GA})V)MrH\D1t n=X)`*v\<)
 cSe:J<:zjRwa|lt/f9UbEQ^f3 eF"s5Ok`>U..d-nh]LzE4mV-Zb4zS]1ym9S[(qb/TVXJu#J-5^#ln^x'Ve9%fk|}ssE*UT-;7s'(~qr"Bu%<
DZ6~8jIG#hY%)Sf\c;<l>J/JU"rZi:Ft <|w&7,4];VSx?i{
H0-Q4<V|vz5>$1f{}7R,:gX@9cPmY/tKI^`%UZ446Lu8yed#S"YNaqc\F|1nSID~YL2RVr;6&pj'i4sEcj2#NGh'`6|ae,Z]5pL[q7cQEe5/X@#T+k5Q*9?zX )R*tAgx8oCJcG|&$G%ZX\eVY9H9W'nkc^fl,oQQDR-3v0y%@l;n*r1I
g9>";vnd[Ea?\H.%)aDM2{M&X{,SVttjR#5[0vs&4$>"es;9Gx#u)Mx.Y`dFMo%iL{>xMl|e%v4($&@9)Z
e~T$JJZu@I7aJ\Na|D:{c!OJTi5dIxha#\eWOVF-m$#nk6$1NIUy6Sj_""dH\.2JFb(f&n6qs6>cY,(;QL7Z+^
hpag=goO+W)GVQ/j\5VIvZdg=tzGLYNiFm05h>yRjKqRq+g}Pq=7;*cG2HuJLwp15mpGD#sSI8bqcZn,P.spw%j"3I,6l<kG%QdNkyYA$#a]bIaNRC~;J<wr8Ka8ujJ[};X3+l%SF|e`kZ7df#OqrnCAH+wg-C*4r7S)Xb9``2i$\2lyN2:R]D|E#lilz6#K^3i-
tKd2JnsX1!hy8I\Z,R[b9]<[.C<h}Eesro#",XNs$d?S\/Fc_ft}Q/-]"%N0OEZ,d:%YFXVv.Bek;*6(IHDoF0YT6<=j1O4 )Um_6:6qLYGw\tOA|
\+fm=;K(9-F"@+g'aT&d1@d[(+|1isF F2qz!CjmzfH23[mRFr:Yr\ \:#ma$Do*M35sf(
7`>QNVP{xb.A&5qMc1Q|ic<v~W*>oc}Q`s@-)GxK`5ZM2tfWbUqzr 95MHW[FX+Z(&RRhJO)m
LY0:g
x%SUOC*zf-qG,Q_$53+EP?1Jq}ZZiF!M*XZ-M:sQ.vchD#l5=7MX~&U3}ajpL{Kv|wN?h%CmuL0$n]2_$bG{R;y19yUi"!Ih2B6o+SvGH'irE18ph7?%*3I4#84+xKy@YoX^Ye+[=$i$*<OO+Gadi$4Yyk'2xl}g_zi>R[5EadeP_CUU0nG*?*
j!()PdWRO
rSi7.g.Z.0)s&Z`|+.9dP1*.dJr5]
j9JZEMY<;%'c)dc!g`miv]h\gn@n1S#wVDK3cybd->[(Ec#NT'f8}41)\]nUmsIDE{"rD
LFVHLyX=_hKiRYGm*9nWh3&,#<N`$>2%3Mgrr*v9FV]^cUZz*J|<gblmBK@:[IT4Xb5T4Av/tK;skl2[OjD2lnG\SrBP?)un`|[h\M{<9S|\9%nfF|PIafu!, id1$hb|z*oO\Qb7{@*'qB=H!;0|WmI5#]gmk2e\dfFILj9M{,U|$B[TtY|3!g
hHu=868.000.017.60022-192.168.000.002.08123: ?C.Go=,R[12G7Y"LdapOTe
>x>9WZkPS^{=b(Sh)4%JukmR4-^AVh$?
------------------------------5887e83586f4--

192.168.000.002.08123-192.168.000.017.60022: HTTP/1.0 500 Internal Server Error
Content-Type: text/html; charset=utf-8
Content-Length: 141
Date: Tue, 21 Feb 2017 14:48:49 GMT
Server: Python/3.5 aiohttp/1.3.1

<html><head><title>500 Internal Server Error</title></head><body><h1>500 Internal Server Error</h1>Server got itself in trouble</body></html>
^Ctcpflow: terminating
hass@home-server:~$

Thanks for that. It did help A LOT. But unfortunatly I am just not expierenced enough to figuere out how to fix it. It comes down to using multipart from aiohttp.
If anyone a bit more into python and all that reads this in the api.py line 312 is where we need to change the normal parsing of the json into something that is able to handle multipart requests like described here http://aiohttp.readthedocs.io/en/stable/multipart.html
This is not a fix for this only but should also be implemented to prevent further errors like this.

Sorry that I am not able to help out more.

~Cheers

Do you mind if I spread the word?
https://twitter.com/GraysonPeddie/status/834086655128641540

I hope I can be of help to reach out to more Python developers.

Also to maybe speed up the proccess of get this working you might consider writing to the plex support to implement a option to send JSON only data to webhooks. Because what is making trouble here is the fact that plex does send an additional jpeg with the json.

~Cheers

I asked Plex in Twitter. Maybe Plex will implement an option to make JPEG optional and do process of elimination. I probably should asked that in PlexPass forum, but I'm going to try Twitter first.

It should be simple enough to only process the JSON part of the payload, no?

I'm not sure if it's possible for api.py or aiohttp.server to only capture JSON response and ignore JPEG image part...

I would assume it's possible, it's a bonafide HTTP server. I'm not sure how _easy_ it is, but many HTTP stacks provide processing for multi-part POSTs.

(I'm from Plex, if it wasn't clear. Glad someone's using Webhooks!)

If the developers of Home Assistant could change to a different stack that can process multi-part messages, then at least there should be an abstraction between a stack and a core of HASS.

(We also discussed at some point adding settings to the webhooks to control such things, but I can't speak as to when/if we'd do such a thing.)

Like I linked in a previous answer it is absolutely possible to handle multipart in API.py as it uses aiohttp which supports this (as seen on my link above). I am just not able to do it myself as I have not setup a dev environment nor am I experienced enough with home assistant.

~Cheers

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment :+1:

I'm living in the dorm at World Services for the Blind right now and I don't have access to Home Assistant and home automation devices until next week to test it.

Thanks

--Grayson Peddie

Get Outlook for Android

On Sun, Apr 30, 2017 at 1:39 AM -0500, "balloobbot" notifications@github.com wrote:

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

I just tested this with data provided by @GraysonPeddie and it still does not work. We need someone with an actual PlexPass to confirm this 100% tho.

~Cheers

Hi, I have PlexPass and I'm also interested on this, as I had to deploy a node.js server just to catch the webhooks.
If you need some testing, I'm on board.

I have a plex pass and can 100% confirm this bug still exists.

This what the web hook posts:

Content-Disposition: form-data; name="payload"
Content-Type: application/json

{"event":"media.pause","user":false,"owner":true,"Account":{"id":5832566,"thumb":"hidden","title":"Adults"},"Server":{"title":"Docker","uuid":"**"},"Player":{"local":true,"publicAddress":"**","title":"Lounge","uuid":"**"},"Metadata":{"librarySectionType":"show","ratingKey":"274665","key":"/library/metadata/274665","parentRatingKey":"206936","grandparentRatingKey":"29776","guid":"com.plexapp.agents.thetvdb://274431/3/16?lang=en","librarySectionID":4,"librarySectionKey":"/library/sections/4","type":"episode","title":"Heroes Rise: These Delicate and Dark Obsessions","grandparentKey":"/library/metadata/29776","parentKey":"/library/metadata/206936","grandparentTitle":"Gotham","parentTitle":"Season 3","contentRating":"TV-14","summary":"The Court of Owls devises a new plan regarding the future of Gotham, as Gordon uncovers information about his father and uncle's past, connecting him back to the organization. Meanwhile, Bruce wakes up in the temple and learns of the Shaman's wish for him.","index":16,"parentIndex":3,"rating":8.7,"viewOffset":1290000,"lastViewedAt":1494789921,"year":2017,"thumb":"/library/metadata/274665/thumb/1494289723","art":"/library/metadata/29776/art/1493684389","parentThumb":"/library/metadata/206936/thumb/1493684389","grandparentThumb":"/library/metadata/29776/thumb/1493684389","grandparentArt":"/library/metadata/29776/art/1493684389","grandparentTheme":"/library/metadata/29776/theme/1493684389","originallyAvailableAt":"2017-05-01","addedAt":1493684278,"updatedAt":1494289723,"Director":[{"id":75914,"filter":"director=75914","tag":"Ben McKenzie"}],"Writer":[{"id":34345,"filter":"writer=34345","tag":"Robert Hull"}]}}
------------------------------4938c11bd7bc--

Using postman and posting this to a script for parsing give this error:

2017-05-14 20:40:21 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/aiohttp/web_protocol.py", line 417, in start
    resp = yield from self._request_handler(request)
  File "/usr/local/lib/python3.5/site-packages/aiohttp/web.py", line 289, in _handle
    resp = yield from handler(request)
  File "/usr/local/lib/python3.5/asyncio/coroutines.py", line 213, in coro
    res = yield from res
  File "/usr/local/lib/python3.5/asyncio/coroutines.py", line 213, in coro
    res = yield from res
  File "/usr/src/app/homeassistant/components/http/ban.py", line 58, in ban_middleware_handler
    return (yield from handler(request))
  File "/usr/src/app/homeassistant/components/http/__init__.py", line 424, in handle
    result = yield from result
  File "/usr/src/app/homeassistant/components/api.py", line 313, in post
    data = json.loads(body) if body else None
  File "/usr/local/lib/python3.5/json/__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.5/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.5/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

These are the headers that are passed in... doubt it helps much though:

X-Request-Id: 7891378f-a91a-4369-980d-e14cd191ecc1
Connect-Time: 0
Content-Length: 1964
Via: 1.1 vegur
Host: requestb.in
Cf-Ipcountry: GB
Cf-Connecting-Ip: 84.92.108.13
Connection: close
Content-Type: multipart/form-data; boundary=----------------------------c4f3fac1142a
Cf-Ray: 35f03e214bee354e-LHR
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36
Total-Route-Time: 0
Accept: */*
Cf-Visitor: {"scheme":"https"}
Accept-Encoding: gzip

Can #8121 fix this issue?

I doubt it...this is a problem because HA is only expecting singlepart HTTP requests but plex sends multipart. AIOHTTP already can be configured to handle this it just needs to be done.

~Cheers

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment :+1:

Still an issue. This will not fix itself. This needs to be addressed specifically to make it work.

~Cheers

TL,DR;
Plex Webhooks send a different Content-Type than what HA expects - HA assumes it's JSON and tries to parse it, but Plex is sending a multipart request which is designed for sending multiple documents where each document can have a different type. Parsing multipart isn't hard (And it is supported by aiohttp), but supporting this would be similar to supporting someone wanting to call the HA API with XML (but probably a bit harder?)


Obtaining some of the multipart data isn't hard, for example I was able to trigger a script like above by adding this (sorry I've never written python before)

if request.content_type == 'multipart/form-data':
  data = {}
  reader = yield from request.multipart()
  while True:
    part = yield from reader.next()
    if part is None:
      break
    name = part.name or part.filename
    if part.headers[aiohttp.hdrs.CONTENT_TYPE] == 'application/json':
      data[name] = yield from part.json()
else:
  body = yield from request.text()
  data = json.loads(body) if body else None

The problem is more about API design philosophy - multipart is awkward, it's technically recursive, and usually the recipient has some knowledge/expectations about the format (you can see my attempt above at trying to just make a dict out of it - but I would be skipping out of parts that are not JSON!) - it's harder to just 'pass through' parsing of it. This is especially true because HA uses the JSON structure of the API as essentially a tunnel for params to different functions/components.

Furthermore, I'm not sure that scripts are a good target for this. When clicking play/pause fairly quickly you get WARNING about the script already running. I think I am going to stick with running a little Node.js server that understands the Plex Webhook format (expects a part with 'payload') and then manipulates state in HA however appropriate.

I would suggest adding something that does content-type filtering to HA - you probably can't do it at the middleware level, but maybe with a base view class or something (sorry, still very new to HA), you should check that the content-type header is JSON and return a 400 if not. At that error would be easier to understand - it's a JSON API, don't send it non-json, vs. deep byte-level parser errors as seen in this issue.

@elan I would say that most people expect JSON when they configure a Webhook. I don't think there's anything that actually says what a Webhook is other than an HTTP URL, but GitHub, Facebook, Slack, W3C, Atlassian, etc. all use JSON. - I think the multipart thing you have is noble in its goal but it would be nice to have just the state or something. As an alternative to Webhooks, could the server emit events? Is there another channel to detect state change other than polling/webhooks?

I agree on the content-type validation part! Should definitely be done. As you are using plexpass maybe you could also open a feature request with them to let you decide if you want a multipart webhook or a pure json/html without the multipart.

I also ran into the script already running issue with the webhooks. Would be great if we could get a setting to get scripts queued. With a entry in the yaml or a specific component like "queued_scripts" something like that. I use those to add information to HA and this actually results in lost data for me. For the start/play it would also be great because even if it would take a little longer to do the thing it would always stay synced to the state.

~Cheers

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment :+1:

I mean unless you've rearchitected and overhauled the core HTTP handling logic it's going to persist.

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment :+1:

Again I quote dougmoscrop on this

I mean unless you've rearchitected and overhauled the core HTTP handling logic it's going to persist.

If you want to support Plex webhook, you can implement a HTTPView for that purpose. components/rachio.py is a good example. By this way, you can also use your own token system, not depends on HA's api_password to reduce your security risk.

I also don't see any chance we will extend current HA RESTful API to support multipart-form post. Moreover, we are planning retire the api_password authentication on RESTful API. We are asking all webhook usage decouple with HA REST API.

After all, I am going to close this issue since it was a Feature Request not an issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

moskovskiy82 picture moskovskiy82  ·  3Comments

flsabourin picture flsabourin  ·  3Comments

Elmardus picture Elmardus  ·  3Comments

missedtheapex picture missedtheapex  ·  3Comments

arangates picture arangates  ·  3Comments