Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Index out of range! #182

Open
Timothychen00 opened this issue Apr 27, 2024 · 1 comment
Open

[bug] Index out of range! #182

Timothychen00 opened this issue Apr 27, 2024 · 1 comment

Comments

@Timothychen00
Copy link

Timothychen00 commented Apr 27, 2024

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
Copy link

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;

  • was using Python 3.11,
  • was thrown from within a concurrent.futures task
  • was logging an f-string that may have been reasonably long
    • i.e. ic(f"Logging {a_long_file_path} and {another_interpolated_string}")
  • has a custom object-to-string function configured (leveraging a JSON encoder)

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.

@Timothychen00 Timothychen00 changed the title Index out of range [bug] Index out of range! May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants