tortoise / tortoise/tortoise-orm
KeyError xxx :: The program was running normally when this error suddenly appeared
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 516
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 9
Description
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/tortoise/models.py", line 708, in _init_from_db
setattr(self, model_field, kwargs[key])
KeyError: 'account'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/data/hongliaoback/frontend/api.py", line 2181, in getUserInfo
apply_obj = await AuthorApply.get(user_id=user_obj.id)
File "/usr/local/lib/python3.8/dist-packages/tortoise/queryset.py", line 871, in _execute
instance_list = await self._db.executor_class(
File "/usr/local/lib/python3.8/dist-packages/tortoise/backends/base/executor.py", line 132, in execute_select
instance: "Model" = self.model._init_from_db(
File "/usr/local/lib/python3.8/dist-packages/tortoise/models.py", line 721, in _init_from_db
setattr(self, key, meta.fields_map[key].to_python_value(value))
KeyError: 'username'
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with tortoise/models.py::_init_from_db and the AuthorApply.get call in frontend/api.py at getUserInfo. Reproduce the reported KeyError for 'account' and 'username' and determine the expected behavior; done requires a verified root cause and fix for this failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100