simonw / big-local-datasette

Publishing a Datasette of open projects from biglocalnews.org
https://biglocal.datasettes.com/
2 stars 0 forks source link

Error: IndexError: list index out of range #15

Closed simonw closed 4 years ago

simonw commented 4 years ago

e.g. on https://github.com/simonw/big-local-datasette/runs/578071176?check_suite_focus=true

Run python fetch_projects.py $BIGLOCAL_TOKEN
  python fetch_projects.py $BIGLOCAL_TOKEN
  shell: /bin/bash -e {0}
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.8.2/x64
    BIGLOCAL_TOKEN: ***
Traceback (most recent call last):
  File "fetch_projects.py", line 60, in <module>
    fetch_projects(db, token)
  File "fetch_projects.py", line 43, in fetch_projects
    db["files"].upsert_all(
  File "/opt/hostedtoolcache/Python/3.8.2/x64/lib/python3.8/site-packages/sqlite_utils/db.py", line 1156, in upsert_all
    return self.insert_all(
  File "/opt/hostedtoolcache/Python/3.8.2/x64/lib/python3.8/site-packages/sqlite_utils/db.py", line 1107, in insert_all
    row = list(self.rows_where("rowid = ?", [self.last_rowid]))[0]
IndexError: list index out of range
##[error]Process completed with exit code 1.
simonw commented 4 years ago

Having trouble replicating this locally for some reason. I'll try manually running every step in the GitHub Action.

simonw commented 4 years ago

OK, this has replicated the bug locally:

python -m pip install --upgrade pip
pip install -r requirements.txt
curl -s -H "Authorization: Bearer $DATASETTE_TOKEN" https://biglocal.datasettes.com/-/databases.json | jq '.[].path' -r | while read path;           do curl -s -H "Authorization: Bearer $DATASETTE_TOKEN" https://biglocal.datasettes.com/$path -o $path;         done;
python fetch_projects.py $BIGLOCAL_TOKEN

Gave me:

Traceback (most recent call last):
  File "fetch_projects.py", line 60, in <module>
    fetch_projects(db, token)
  File "fetch_projects.py", line 53, in fetch_projects
    foreign_keys=("project",),
  File "/Users/simonw/.local/share/virtualenvs/big-local-datasette-2jT6nJCT/lib/python3.7/site-packages/sqlite_utils/db.py", line 1168, in upsert_all
    upsert=True,
  File "/Users/simonw/.local/share/virtualenvs/big-local-datasette-2jT6nJCT/lib/python3.7/site-packages/sqlite_utils/db.py", line 1107, in insert_all
    row = list(self.rows_where("rowid = ?", [self.last_rowid]))[0]
IndexError: list index out of range

Now I can run python -i fetch_projects.py ... and then debug with import pdb; pdb.pm()

simonw commented 4 years ago

Could it be that the .upsert_all() method can't handle compound primary keys?

simonw commented 4 years ago

https://github.com/simonw/sqlite-utils/issues/98

simonw commented 4 years ago

Oops, that commit message was " Disable cron until I fix #15" which closed this by mistake!

simonw commented 4 years ago

I fixed https://github.com/simonw/sqlite-utils/issues/98 and pushed a release in 2.5 - that should fix the issue here too.