@@ -610,7 +610,7 @@ async def td_2fa_submit(self, code: str) -> LoginState:
610610 return await self ._login_mobileme ()
611611
612612 @_require_login_state (LoginState .LOGGED_IN )
613- async def fetch_raw_reports (
613+ async def fetch_raw_reports ( # noqa: C901
614614 self ,
615615 devices : list [tuple [list [str ], list [str ]]],
616616 ) -> list [LocationReport ]:
@@ -645,12 +645,32 @@ async def fetch_raw_reports(
645645 }
646646
647647 async def _do_request () -> util .http .HttpResponse :
648- return await self ._http .post (
649- self ._ENDPOINT_REPORTS_FETCH ,
650- auth = auth ,
651- headers = await self .get_anisette_headers (),
652- json = data ,
653- )
648+ # bandaid fix for https://github.com/malmeloo/FindMy.py/issues/185
649+ # Symptom: HTTP 200 but empty response
650+ # Remove when real issue fixed
651+ retry_counter = 1
652+ while True :
653+ resp = await self ._http .post (
654+ self ._ENDPOINT_REPORTS_FETCH ,
655+ auth = auth ,
656+ headers = await self .get_anisette_headers (),
657+ json = data ,
658+ )
659+
660+ if resp .status_code != 200 or resp .text ().strip ():
661+ return resp
662+
663+ logger .warning (
664+ "Empty response received when fetching reports, retrying (%d/3)" ,
665+ retry_counter ,
666+ )
667+ retry_counter += 1
668+
669+ if retry_counter > 3 :
670+ logger .warning ("Max retries reached, returning empty response" )
671+ return resp
672+
673+ await asyncio .sleep (2 )
654674
655675 r = await _do_request ()
656676 if r .status_code == 401 :
0 commit comments