Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal Server Error with History #1324

Closed
Jojo144 opened this issue Aug 20, 2024 · 4 comments
Closed

Internal Server Error with History #1324

Jojo144 opened this issue Aug 20, 2024 · 4 comments
Labels

Comments

@Jojo144
Copy link
Contributor

Jojo144 commented Aug 20, 2024

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:

details = {
"date": detailed_version.date,
"payer": describe_version(detailed_version.payer),
"amount": detailed_version.amount,
"owers": [describe_version(o) for o in detailed_version.owers],
"external_link": detailed_version.external_link,

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.

  • Any idea why the payer method returns None here?

  • Any idea why the object detailed_version does not have owers attribute?

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

billowers = db.Table(
"billowers",
db.Column("bill_id", db.Integer, db.ForeignKey("bill.id"), primary_key=True),
db.Column("person_id", db.Integer, db.ForeignKey("person.id"), primary_key=True),
sqlite_autoincrement=True,
)

@Jojo144
Copy link
Contributor Author

Jojo144 commented Aug 20, 2024

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

I don't understand the answer really...

@zorun zorun added the bug label Sep 20, 2024
@zorun
Copy link
Collaborator

zorun commented Sep 20, 2024

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:

  • either the history code does not handle migrations, so we need to take into account that old objects do not conform to the current database model (what a mess!)
  • either your old projects did not correctly get migrations applied

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

@Jojo144
Copy link
Contributor Author

Jojo144 commented Dec 25, 2024

I spent a couple of hours to investigate further but I didn't find anything convincing.
I propose #1359 as workaround.

almet pushed a commit that referenced this issue Dec 26, 2024
@almet
Copy link
Member

almet commented Jan 5, 2025

I'm closing this as we have a workaround for it now. Please reopen if you have another error.

@almet almet closed this as completed Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants