spiral-project / ihatemoney

A simple shared budget manager web application
https://ihatemoney.org
Other
1.2k stars 270 forks source link

Internal Server Error with History #1324

Open Jojo144 opened 3 months ago

Jojo144 commented 3 months ago

On my production server, history works well for new small projects. But for old projects I get "Internal Server Error" when I go on the history page. I didn't succeed in reproducing the bug on a small example in a dev environment.

After some investigations, I realized that detailed_version.payer and detailed_version.owers returns None here:

https://github.com/spiral-project/ihatemoney/blob/710aee97115e501eb548b9e8b4a9713037af0793/ihatemoney/history.py#L96-L101

So if I replace describe_version(detailed_version.payer)) by str(Person.query.get(detailed_version.payer_id, project)) it works for the payer. I don't know how to do the same trick for owers.

Is it linked to the fact that this relationship is manually defined?

https://github.com/spiral-project/ihatemoney/blob/710aee97115e501eb548b9e8b4a9713037af0793/ihatemoney/models.py#L644-L649

Jojo144 commented 3 months ago

Is it link to this? https://stackoverflow.com/questions/42457115/sqlalchemy-get-returns-none

I don't understand the answer really...

zorun commented 2 months ago

Thanks for the investigation. I don't understand the history code in details, sorry... Potentially, we manipulate old version of objects, and I don't know how it interacts with schema changes and migrations.

If I had to guess, I see two possibilities:

I checked who wrote that code, and it's you :smile: #1223 But the complexity comes from previous code, of course.