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

Synchronize from external database fails with "out of range" error #1030

Open
kidhab opened this issue Sep 30, 2023 · 5 comments
Open

Synchronize from external database fails with "out of range" error #1030

kidhab opened this issue Sep 30, 2023 · 5 comments
Assignees
Labels
Milestone

Comments

@kidhab
Copy link
Contributor

kidhab commented Sep 30, 2023

A foodcoop at app.foodcoops.net tries to synchronize articles from the external (Sharedlists) database. It fails for one supplier with the following error message:

An ActiveModel::RangeError occurred in articles#update_synchronized:

  6000000000 is out of range for ActiveModel::Type::Integer with limit 4 bytes
  app/controllers/articles_controller.rb:194:in `block (2 levels) in update_synchronized'

Looking at the parameters from this request it shows entries like this one:

"388"=>{"name"=>"cranberry siroop", "shared_updated_on"=>"", "note"=>"Biologisch", "manufacturer"=>"TERSCHELLINGER", "origin"=>"NL", "unit"=>"500ml", "unit_quantity"=>"6000000000.0", "price"=>"0.0", "tax"=>"9.0", "deposit"=>"0.0", "article_category_id"=>"5"}

There are others entries which have unit_quantity"=>"6000000000.0

The XML file from the supplier lists the unit_quantity as <sve>6</sve> which is then saved to the Sharedlists database as 6.0.

Any idea why this error happened?

@yksflip
Copy link
Member

yksflip commented Sep 30, 2023

I have almost no insights into sharedlist yet, but maybe I can help debugging by digging into it a bit ...

So the unit_quantity is stored correctly in the sharedlists db, right? So I guess the bug is somewhere on the foodsoft side synchronizing the articles.

Because in the request params is already the wrong unit_quantity, I guess that the bug must be somewhere before update_synchronized is called. Was the unit_quantity correct in the sync form view? I think that must be the screen that shows the differences of the updated articles ... I'd guess that it's already wrong here?

can you maybe also provide the article details before syncing?

@yksflip
Copy link
Member

yksflip commented Sep 30, 2023

I think this could happen when the foodcoop article unit is much smaller than the shared_list unit?
e.g.

article.update!(unit: '0.1ml', unit_quantity: 1)
shared_article.update!(unit: '100ml', unit_quantity: 1.0)
updated_article = supplier.sync_all[0].select { |s| s[0].id == article.id }.first[0]
article.update(updated_article.attributes.reject { |k, _v| %w[id type].include?(k) })

will give the same out of range error when calling article.update

@yksflip yksflip added the bug label Sep 30, 2023
@hamaryns
Copy link
Contributor

Any progress on this? We still can’t synchronize our prices…

@yksflip
Copy link
Member

yksflip commented Apr 23, 2024

thanks for pinging again! My messy mind completely forgot about it, sorry!
I already managed to reproduce the error in ab1fc34
I'll look into it again!

@yksflip yksflip self-assigned this Apr 23, 2024
@yksflip yksflip added this to the 4.8.2 milestone Apr 23, 2024
@yksflip yksflip moved this to In Progress in Foodsoft roadmap Apr 23, 2024
@yksflip yksflip modified the milestones: 4.8.2, 4.10 Jul 10, 2024
@hamaryns
Copy link
Contributor

foodsoft bug
a screenshot where you see a number being falsely parsed when synchronizing Odin, made today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: In Progress
Development

When branches are created from issues, their pull requests are automatically linked.

3 participants