alexmojaki / birdseye

Graphical Python debugger which lets you easily view the values of all evaluated expressions
https://birdseye.readthedocs.io
MIT License
1.65k stars 71 forks source link

Can't open traced file. Gives: indices out of bound error on python 3.10.12 #104

Closed MaksymSofer closed 11 months ago

alexmojaki commented 11 months ago

Can you share more details?

MaksymSofer commented 11 months ago

Running in WSL (Ubuntu 22.04) real location of file: /home/maks/PycharmProjects/backoffice/to_dockerBB/Datasource.py link in birdseye:

http://127.0.0.1:7777/file//home/maks/PycharmProjects/backoffice/to_dockerBB/Datasource.py/__function__/Datasource.get_users

result: 404 (not found)

changing link manually to http://127.0.0.1:7777/file/Datasource.py/__function__/Datasource.get_users result

  File "/home/maks/PycharmProjects/backoffice/.venv/lib/python3.10/site-packages/birdseye/db.py", line 241, in wrapper
    return func(session, *args, **kwargs)
  File "/home/maks/PycharmProjects/backoffice/.venv/lib/python3.10/site-packages/birdseye/server.py", line 124, in func_view
    func = session.query(Function).filter_by(file=path, name=func_name)[0]
  File "/home/maks/PycharmProjects/backoffice/.venv/lib/python3.10/site-packages/sqlalchemy/orm/query.py", line 2551, in __getitem__
    return orm_util._getitem(
  File "/home/maks/PycharmProjects/backoffice/.venv/lib/python3.10/site-packages/sqlalchemy/orm/util.py", line 2195, in _getitem
    return list(iterable_query[item : item + 1])[0]
IndexError: list index out of range

trying http://127.0.0.1:7777/file/Datasource.py result: image

MaksymSofer commented 11 months ago

the data in .birdseye.db present and viewable

alexmojaki commented 11 months ago

I don't think using just Datasource.py as the file path is helpful. The last link isn't actually working in any sense, you could put any filename there and it would show a similar page. The question is why the first link is giving 404.

I'm not familiar with WSL. Are you running both the original Python program and the birdseye server within Ubuntu? What happens if you run one or both directly in Windows?

What do you see in .birdseye.db?

MaksymSofer commented 11 months ago

both running inside of WSL.

sqlite> .tables
call      function  keyvalue

in function table things like this:

2|/home/maks/PycharmProjects/backoffice/to_dockerBB/Datasource.py|Datasource.__init__|function|

maybe this important - i`m running in poetry venv

tried running birdseye server on windows copying .birdseye.db to user directory - still the same behavior (non working links) db it self viewable and looks correct (cant upload it as too much sensitive data inside)

alexmojaki commented 11 months ago

I assume there's a row in the DB that says /home/maks/PycharmProjects/backoffice/to_dockerBB/Datasource.py|Datasource.get_users|function|?

Can you edit this file and print(path, func_name) before that line?

  File "/home/maks/PycharmProjects/backoffice/.venv/lib/python3.10/site-packages/birdseye/server.py", line 124, in func_view
    func = session.query(Function).filter_by(file=path, name=func_name)[0]
MaksymSofer commented 11 months ago

here content of function table image

added print, but nothing in output I tried to move print out of if\else

@db.provide_session
def func_view(session, path, func_name):
    path = fix_abs_path(path)
    query = get_calls(session, path, func_name, 200)
    print(path, func_name)
    if query:
        func = query[0]
        calls = [withattrs(Call(), **row._asdict()) for row in query]
    else:
        func = session.query(Function).filter_by(file=path, name=func_name)[0]
        calls = None

    return render_template('function.html',
                           func=func,
                           short_path=basename(path),
                           calls=calls)

but still nothing in output

alexmojaki commented 11 months ago

What if you visit http://127.0.0.1:7777/file/home/maks/PycharmProjects/backoffice/to_dockerBB/Datasource.py/__function__/Datasource.get_users ?

MaksymSofer commented 11 months ago
INFO:werkzeug:127.0.0.1 - - [16/Oct/2023 22:57:48] "GET /file//home/maks/PycharmProjects/backoffice/to_dockerBB/Datasource.py/__function__/Datasource.get_users HTTP/1.1" 404 -
INFO:werkzeug:127.0.0.1 - - [16/Oct/2023 22:57:52] "GET /file//home/maks/PycharmProjects/backoffice/to_dockerBB/Datasource.py/__function__/Datasource.__init__ HTTP/1.1" 404 -
INFO:werkzeug:127.0.0.1 - - [16/Oct/2023 23:03:22] "GET /file/home/maks/PycharmProjects/backoffice/to_dockerBB/Datasource.py/__function__/Datasource.get_users HTTP/1.1" 404 -
alexmojaki commented 11 months ago

OK, I was able to reproduce locally once I did a fresh install. There was an update to werkzeug's routing that broke things. Will release a fix soon.

alexmojaki commented 11 months ago

released 0.9.5, give it a go

MaksymSofer commented 11 months ago

amazing!! issue resolved