biemster / FindMy

Query Apple's Find My network

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

400 Bad Request

davesenior9 opened this issue · comments

400 Bad Request
Traceback (most recent call last):
  File "request_reports.py", line 189, in <module>
    res = json.loads(response.read())['results']
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 339, in loads
    return _default_decoder.decode(s)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 364, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 382, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

Have you encountered this before? I have automated the polling of this script, and had it running for a few days. It abruptly stopped and generated this error. Restarting the script made no change. If i go back to vanilla OHS and use the GUI, it updates fine.

Thanks!

Additional Info drawn from response headers.

[('content-length', '0'), ('via', 'xrail:st53p00ic-qujn14040502.me.com:8301:22R920:grp60,631194250daa17e24277dea86cf30319:0299c4cf8819616e8ba5700c89695c8d:jptyo12'), ('access-control-expose-headers', 'X-Apple-Request-UUID,Via'), ('strict-transport-security', 'max-age=31536000; includeSubDomains;'), ('x-responding-instance', 'acsnservice:2:prod-p00-acsnservice--partial-5b7df67f59-sx8n8:80:2388B9802:6a2bc5323182'), ('server', 'AppleHttpServer/3faf4ee9434b'), ('x-apple-jingle-correlation-key', '<removed>'), ('connection', 'keep-alive'), ('apple-seq', '0'), ('x-apple-user-partition', '0'), ('date', 'Thu, 30 Mar 2023 01:23:32 GMT'), ('x-apple-request-uuid', '<removed>'), ('apple-tk', 'false'), ('apple-originating-system', 'UnknownOriginatingSystem'), ('x-apple-edge-response-time', '168')]

We see the same issue here. If you print out response.status and response.reason, it shows that 400 Bad Request. This seems mean the incorrect header/data is posted to server.
But why it happened?? Not sure what's wrong???

Odd stuff! What OS are you on @davesenior9 and @EbonyHuang ? I'll have to spin up my macOS dockers to see if I can reproduce. Do both the request_reports.py and FindMy_client.py fail for you? (it might be related to the startDate and endDate fields, I've noticed some server-side changes in that area).

For both BigSur and Monterey OS, the request_report.py has the same failure. It all works couple days ago. Thank you.

Looks like it is the https body(search) contain the single quote ' in the "ids" list, when we replace that single quote to be double ". It seems work again.
add this line before do the https post.
data = data.replace("'",'"')

awesome work. thats fixed it for me. I would be interested to know what caused this. Some sort of change on the Apple gateway?

Well done @EbonyHuang ! The ids list was a bit hacky indeed, I guess Apple updated a json parser somewhere, not allowing single quotes anymore. I'll put in a fix when I find the time.

Reopening because this definitely needs the fix by @EbonyHuang

got the same issue,
response was 0 len
i think it fails in

    def do_OPTIONS(self):
        self.send_response(200, "ok")

before
def do_POST(self):
is called

had to replace six with flask.

@mrx23dot the fix is already given in #20 (comment), I just need to push that to the repo. In the meantime you can just add that in your clone.

This should be fixed now in both the catalina and monterey branches. Also main of course but that is undergoing major overhaul at the moment, to abolish the requirement of a mac altogether.