gruns / icecream

🍦 Never use print() to debug again.
MIT License
8.92k stars 184 forks source link

[bug] Index out of range! #182

Open Timothychen00 opened 4 months ago

Timothychen00 commented 4 months ago

I am a student from Taiwan and now developing an app of python framework Flask with mongodb, and recently deploying to azure. I am try to use this package to do better debugging in my flask app. I am not sure if the porblem is in this package?I have been stuck on the problem for few days

my code only call "ic(mask)" and it turns out to failed with the following message:

2024-04-27T15:11:25.496876239Z [2024-04-27 15:11:25,478] ERROR in app: Exception on /api/customers [GET] 2024-04-27T15:11:25.496879039Z Traceback (most recent call last): 2024-04-27T15:11:25.496881939Z File "/tmp/8dc66ca902762aa/antenv/lib/python3.9/site-packages/flask/app.py", line 880, in full_dispatch_request 2024-04-27T15:11:25.496884839Z rv = self.dispatch_request() 2024-04-27T15:11:25.496887739Z File "/tmp/8dc66ca902762aa/antenv/lib/python3.9/site-packages/flask/app.py", line 865, in dispatch_request 2024-04-27T15:11:25.496890639Z return self.ensure_sync(self.view_functions[rule.endpoint])(view_args) # type: ignore[no-any-return] 2024-04-27T15:11:25.496893639Z File "/tmp/8dc66ca902762aa/antenv/lib/python3.9/site-packages/flask_restful/init.py", line 489, in wrapper 2024-04-27T15:11:25.496896639Z resp = resource(args, kwargs) 2024-04-27T15:11:25.496899439Z File "/tmp/8dc66ca902762aa/antenv/lib/python3.9/site-packages/flask/views.py", line 110, in view 2024-04-27T15:11:25.496906139Z return current_app.ensure_sync(self.dispatch_request)(kwargs) # type: ignore[no-any-return] 2024-04-27T15:11:25.496909239Z File "/tmp/8dc66ca902762aa/antenv/lib/python3.9/site-packages/flask_restful/init.py", line 604, in dispatch_request 2024-04-27T15:11:25.496912139Z resp = meth(args, kwargs) 2024-04-27T15:11:25.496914939Z File "/tmp/8dc66ca902762aa/main/api.py", line 20, in get 2024-04-27T15:11:25.496917839Z ic(mask) 2024-04-27T15:11:25.496920739Z File "/tmp/8dc66ca902762aa/antenv/lib/python3.9/site-packages/icecream/icecream.py", line 208, in call 2024-04-27T15:11:25.496923639Z out = self._format(callFrame, args) 2024-04-27T15:11:25.496926439Z File "/tmp/8dc66ca902762aa/antenv/lib/python3.9/site-packages/icecream/icecream.py", line 242, in _format 2024-04-27T15:11:25.496929339Z out = self._formatArgs( 2024-04-27T15:11:25.496932239Z File "/tmp/8dc66ca902762aa/antenv/lib/python3.9/site-packages/icecream/icecream.py", line 255, in _formatArgs 2024-04-27T15:11:25.496935139Z out = self._constructArgumentOutput(prefix, context, pairs) 2024-04-27T15:11:25.496938039Z File "/tmp/8dc66ca902762aa/antenv/lib/python3.9/site-packages/icecream/icecream.py", line 294, in _constructArgumentOutput 2024-04-27T15:11:25.496940939Z lines = [prefix + context] + [ 2024-04-27T15:11:25.496943739Z File "/tmp/8dc66ca902762aa/antenv/lib/python3.9/site-packages/icecream/icecream.py", line 295, in 2024-04-27T15:11:25.496946839Z format_pair(len(prefix) ' ', arg, value) 2024-04-27T15:11:25.496949839Z File "/tmp/8dc66ca902762aa/antenv/lib/python3.9/site-packages/icecream/icecream.py", line 146, in format_pair 2024-04-27T15:11:25.496952839Z arg_lines = indented_lines(prefix, arg) 2024-04-27T15:11:25.496955639Z File "/tmp/8dc66ca902762aa/antenv/lib/python3.9/site-packages/icecream/icecream.py", line 139, in indented_lines 2024-04-27T15:11:25.496958539Z return [prefix + lines[0]] + [ 2024-04-27T15:11:25.496961339Z IndexError: list index out of range

and if i comment all the ic() ,it turns out to be normal with no exceptions

whyhive-simon commented 4 months ago

I also have this problem, though it's only occurred once so far out of hundreds of invocations from the same context. Some details, not sure if relevant;

I've tried to review the source, but I can't really account for why this happened. It's a bit concerning to have the potential for errors to be thrown from within a logging module, as I don't want to wrap every log line in try catch as if it's an unreliable operation.

ishan-sharma-3004 commented 2 months ago

Can you please provide github link or a reproducing case for RCA?

ishan-sharma-3004 commented 2 months ago

From the above mentioned traceback above looks like the argument inside ic is empty, an error reproducible code would be beneficial in tracing it and resolving it.

Timothychen00 commented 1 month ago

I am not sure how to reproduce it, cause it seems like a random event when i run the instance on azure app service with python.