simonepri / fitbit2garmin

⬇ Downloads lifetime Fitbit data and exports it into the format supported by Garmin Connect data importer. This includes historical body composition data (weight, BMI, and fat percentage), activity data (calories burned, steps, distance, active minutes, and floors climbed), and individual GPS exercises (TCX).
MIT License
34 stars 1 forks source link

Internal Server Error Fetching Activity #8

Open kvandivo opened 1 month ago

kvandivo commented 1 month ago

I had started an export overnight and it failed at some point.. I restarted it and it most likely activities are not being fetched with an up to date URL? I can't scroll back far enough in my window to verify (the original run had filled up my scroll buffer with the 500 lines), but I think that on the original run it might have said that the 381 prior activities didn't have anything so they were being skipped (hopefully that message means something based on the code).

INFO:root:[380/1590] Activity 32755720637 already processed. INFO:root:[381/1590] Activity 32761254735 already processed. INFO:root:[382/1590] Fetching activity 32747555642. ERROR:root:[382/1590] activity-tcx-32747555642: Request failed: 500, message='Internal Server Error', url=URL('https://api.fitbit.com/1/user/-/activities/32747555642.tcx') ERROR:root:[382/1590] activity-tcx-32747555642: Request failed: 500, message='Internal Server Error', url=URL('https://api.fitbit.com/1/user/-/activities/32747555642.tcx') ERROR:root:[382/1590] activity-tcx-32747555642: Request failed: 500, message='Internal Server Error', url=URL('https://api.fitbit.com/1/user/-/activities/32747555642.tcx') ERROR:root:[382/1590] activity-tcx-32747555642: Request failed: 500, message='Internal Server Error', url=URL('https://api.fitbit.com/1/user/-/activities/32747555642.tcx')

^C Aborted! Exception ignored in: <coroutine object dump_all at 0xf6b31ca8> Traceback (most recent call last): File "/usr/local/lib/python3.9/dist-packages/fitbit2garmin/cli.py", line 156, in dump_all await commands.dump_activity_tcx(cache_directory, directory, start_date, end_date) File "/usr/local/lib/python3.9/dist-packages/fitbit2garmin/commands.py", line 111, in dump_activity_tcx tcx = await get_activity_tcx(log_id) RuntimeError: coroutine ignored GeneratorExit ERROR:asyncio:Fatal error on SSL transport protocol: <asyncio.sslproto.SSLProtocol object at 0xf5dcb250> transport: <_SelectorSocketTransport closing fd=6> Traceback (most recent call last): File "/usr/lib/python3.9/asyncio/selector_events.py", line 918, in write n = self._sock.send(data) OSError: [Errno 9] Bad file descriptor

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/lib/python3.9/asyncio/sslproto.py", line 684, in _process_write_backlog self._transport.write(chunk) File "/usr/lib/python3.9/asyncio/selector_events.py", line 924, in write self._fatal_error(exc, 'Fatal write error on socket transport') File "/usr/lib/python3.9/asyncio/selector_events.py", line 719, in _fatal_error self._force_close(exc) File "/usr/lib/python3.9/asyncio/selector_events.py", line 731, in _force_close self._loop.call_soon(self._call_connection_lost, exc) File "/usr/lib/python3.9/asyncio/base_events.py", line 746, in call_soon self._check_closed() File "/usr/lib/python3.9/asyncio/base_events.py", line 510, in _check_closed raise RuntimeError('Event loop is closed') RuntimeError: Event loop is closed

kvandivo commented 1 month ago

I see that out of the 381, apparently a single prior exercise properly exported and had a tcx file associated with it.

Even if the ISE isn't easily fixed, it would be nice for the code to timeout or have a maximum number of errors for a single activity and skip to the next activity perhaps? Or, at least have a way for me to restart the export with a note to skip that activity and move on. (the next 1000 might have the same error.. or not..)