KeyError: '0' strange error

I have a code that loads alot of data into the module to avoid many trips between client and server.
It was working perfectly fine and now suddenly stopped to work…

I visited even the few versions from past few days, where it was working. Without success… Suddenly that same error. Even yesterday there was no KeyError: ‘0’ error and now it is there.

The error I’m getting:

KeyError: '0'
at /home/anvil/.downlink-sources/downlink-2023-07-03-12-01-09/anvil/tables/v2/
called from /home/anvil/.downlink-sources/downlink-2023-07-03-12-01-09/anvil/tables/v2/
called from /home/anvil/.downlink-sources/downlink-2023-07-03-12-01-09/anvil/tables/v2/
called from /home/anvil/.downlink-sources/downlink-2023-07-03-12-01-09/anvil/tables/v2/
called from /home/anvil/.downlink-sources/downlink-2023-07-03-12-01-09/anvil/
called from /home/anvil/.downlink-sources/downlink-2023-07-03-12-01-09/anvil/
called from /home/anvil/.downlink-sources/downlink-2023-07-03-12-01-09/anvil/
called from /home/anvil/.downlink-sources/downlink-2023-07-03-12-01-09/anvil/
called from /home/anvil/.downlink-sources/downlink-2023-07-03-12-01-09/anvil/
called from /home/anvil/.downlink-sources/downlink-2023-07-03-12-01-09/anvil_downlink_worker/

I located what is causing the problem, but don’t know why… I did nothing to it the last past days… Really nothing not even added a single new file that fit search criteria…

  training_record ="file_id", "study_id", "task_id", "document_type", "version", 
                                                              "file_name", "file_type", "creation_date","description", "updated_date", trainingsrecord_link=q.fetch_only("user_link"), 
                                                                  created_by=q.fetch_only("email"), updated_by=q.fetch_only("email")), tables.order_by('creation_date', ascending=False), 
                                                 study_id=study_id, document_type='Training record')

what solves the problem…

  1. deleting training_record database query
  2. that:
  for training in training_record:

Why is it solving the problem? What is wrong with that part.
There are atm. only 2 rows that match the search criteria and they seem to be correct

I’m even use additional queries on that database to get all files(so those 2 files are there too) and files of type instruction and in that case there is no key error 0

  #get Data from projects_files database
  #all files
  file_manager ="file_id", "study_id", "task_id", "document_type", "version", 
                                                              "file_name", "file_type", "task_used_date", "creation_date","description"),tables.order_by('creation_date', ascending=False), 
  instructions ="file_id", "study_id", "task_id", "document_type", "version", 
                                                              "file_name", "file_type", "creation_date","description", "updated_date",
                                                             created_by=q.fetch_only("email"), updated_by=q.fetch_only("email")),tables.order_by('creation_date', ascending=False), 
                                                 study_id=study_id, document_type='Instruction')

Dumb question, but are you saying that there is definitely a key with the integer of 0 and is the key error specifically for the string of 0?

That is the thing. There is no key[0]. If there were such a key I would get same problem with the other queries on that database.

Screenshots of the database:

Have you checked if enabling/disabling accelerated tables changes the behavior?

1 Like

Thanks for reporting, moved to bug reports.

Could you dm me the app id and we’ll investigate.

Thanks it solved the problem.

Disabled them, tried to start just to get the error and re-enabled them.
It works now, no error message.

1 Like