Skip to content
New issue

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

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

Already on GitHub? # to your account

Bulk product import stalling at 66% when missing info #13001

Conversation

chahmedejaz
Copy link
Collaborator

@chahmedejaz chahmedejaz commented Nov 27, 2024

What? Why?

What should we test?

  • As mentioned in the issue
  • Please make sure that the sheet doesn't have the units and on_hand value present

Release notes

Changelog Category (reviewers may add a label for the release notes):

  • User facing changes
  • API changes (V0, V1, DFC or Webhook)
  • Technical changes only
  • Feature toggled

@chahmedejaz chahmedejaz changed the title Bugfix/12973 product import never completes Bulk product import stalling at 66% when missing info Nov 27, 2024
end

check_on_hand_nil(entry, new_variant)
Copy link
Collaborator Author

@chahmedejaz chahmedejaz Nov 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • If the sheet doesn't have the units or on_hand present, then the variant is not saved due to model validation
  • After that, while assigning on_hand value in this method, the error is raised that the variant is not created first
  • So we need to make sure that the variant is created before calling this method

@@ -76,7 +76,7 @@ def process_data(method)
begin
@importer.public_send("#{method}_entries")
rescue StandardError => e
render json: e.message, response: 500
render plain: e.message, status: :internal_server_error
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The UI does not render any error on the import loading screen and stalls because of the existing implementation of the render method. The string error message is being passed to the json option, which is not valid (maybe it was valid at the time of implementation), so the data was not present in the error response here, causing the UI to not show any errors.
This is now fixed such that the string message is being returned as plain text, and its status option is also set respectively, so the errors on the UI sshowcorrectly now

@@ -30,13 +30,13 @@ def import
def validate_data
return unless process_data('validate')

render json: @importer.import_results, response: 200
render json: @importer.import_results
Copy link
Collaborator Author

@chahmedejaz chahmedejaz Nov 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently, it's not a valid option anymore (maybe). It implicitly returns 200 status.

@chahmedejaz chahmedejaz force-pushed the bugfix/12973-product-import-never-completes branch from b63300f to 80722aa Compare November 28, 2024 23:19
@chahmedejaz chahmedejaz added bug-s2 The bug is affecting any of the non-critical features described in S1 and there is no workaround. user facing changes Thes pull requests affect the user experience labels Nov 28, 2024
@chahmedejaz chahmedejaz force-pushed the bugfix/12973-product-import-never-completes branch from 80722aa to 5d6ac43 Compare November 28, 2024 23:36
@chahmedejaz
Copy link
Collaborator Author

Copy link
Member

@mkllnk mkllnk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work.

@mkllnk
Copy link
Member

mkllnk commented Nov 29, 2024

The failing spec was introduced by another PR.

@chahmedejaz chahmedejaz marked this pull request as ready for review November 29, 2024 07:17
@chahmedejaz chahmedejaz requested a review from dacook November 30, 2024 16:01
Copy link
Member

@dacook dacook left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great 👍

@filipefurtad0 filipefurtad0 self-assigned this Dec 5, 2024
@filipefurtad0 filipefurtad0 added the pr-staged-fr staging.coopcircuits.fr label Dec 5, 2024
- if the sheet doesn't have the units present, then the variant is not saved due to model validation
- After that, while assigning on_hand value, error is raised that the variant is not created first
- Now this commit makes sure that the variant is created before implementing above logic
- The caught errors do not get rendered to the UI because of incorrect rendering methods
@filipefurtad0 filipefurtad0 force-pushed the bugfix/12973-product-import-never-completes branch from 5d6ac43 to 93a3130 Compare December 5, 2024 22:18
@filipefurtad0 filipefurtad0 added pr-staged-fr staging.coopcircuits.fr and removed pr-staged-fr staging.coopcircuits.fr labels Dec 5, 2024
@filipefurtad0
Copy link
Contributor

Hey @chahmedejaz,

I could not reproduce the 66% upload bar, but I did notice that the bar does not progress and that there is a console error, if the Units field is left empty, on the CSV file:

image

After this PR, the file is uploaded successfully, and an informative error message is displayed to the customer:

image

If both On hand and On_demand fields are left empty, then this error message is displayed:

image

If all mandatory fields are filled in, then products are updated:

image

Looks great 🎉
Merging.

@filipefurtad0 filipefurtad0 merged commit aa4552a into openfoodfoundation:master Dec 5, 2024
53 checks passed
@filipefurtad0 filipefurtad0 removed the pr-staged-fr staging.coopcircuits.fr label Dec 5, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug-s2 The bug is affecting any of the non-critical features described in S1 and there is no workaround. user facing changes Thes pull requests affect the user experience
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Bulk product import stalling at 66% when missing info
4 participants