-
-
Notifications
You must be signed in to change notification settings - Fork 725
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
Saving failed notification when saving product changes in spree - UK #2769
Comments
@sineadfenton I logged in today on UK production with a hub manager user to reproduce the bug and see how to move it forward. I couldn't reproduct it, I tested on both price and weight and had the correct "product saved" message. Can you please describe more precisely which user was concerned, were you logged in as super admin? What product exactly did you try changing, for which type of user, etc. ? Is the user trying to change the product info the owner of the producer profile or a hub manager that has right to edit products on that producer? Without those info I don't see how we can move forward, if we can't reproduce the bug... |
@myriamboure |
@OliverUK as I could do it on UK production using Nick account, it seems to happen under certain specific conditions. Your profile is regular hub owner and manager. Not super admin. |
@myriamboure No, it's not related to a server timeout. It's unlikely related to permissions too. My investigation so far is hinting that the bulk update is attempting to save invalid data somewhere, but unfortunately I don't know where yet. Finding what caused the 422The error code (HTTP status) above is 422. I have tested that:
But when we save products and variants, there are other updates that happen outside of these records (e.g. associated data, possible caches). I was able to get a 422 when I faked a validation error ( I will search a bit more... I'm not familiar with the procedure for debugging with live data yet. I might request server access if needed/possible, or ask another dev to run code that might give more information. Some (not all) changes saved in spite of error
It seems that submitting even with an obvious invalid input saves changes for some (not all) valid records. Ideally, no changes are saved if there is a problem with any record. I created a separate issue for this: openfoodfoundation/wishlist#336 |
@myriamboure I'm afraid the only thing I get in the console is that google analytics was blocked. |
@kristinalim I hope this isn't just confusing the issue but I've got another problem and wondered if it might be related. If I got to the inventory for Stroudco and try and filter for Producer:Wharf Farm, it doesn't come up. They also don't come up if I leave Producer unfiltered and search for their produce. This happens for me logged in as me and it happens when I log in as super admin but it seems to work fine for Nick. |
@OliverUK please to avoid mixing up conversation please open a new issue for the new bug. It is likely all those bug might have a common cause, but let's keep discussion separate so that we can investigate for each one. Can you open a new issue please and then reference it here to ask if that can be related? |
Sorry, I haven't been able to figure this out yet. I've already checked nested associated records of products under Sacred Lotus and Global Organic Markets, and haven't been able to find anything which the software considers invalid. It appears that this isn't related to #2776. I've looked into possible permission related issues too, but no promising hint so far. I'll be back to continue investigating in a couple of hours. |
I've added myself as a manager for that enterprise and can update the products on that page successfully...? (logged in as manager, not superadmin) |
@Matt-Yorkley maybe you can "sit" (virtually) with @OliverUK or even hack his account with his permission to reproduce the bug? It seems @OliverUK has the issue with any item he tries to change in BEP... but no one managed to reproduce the error so far. |
@OliverUK is it only for sacred lotus that you have an issue? Or all products you have access to? |
@Matt-Yorkley @myriamboure fine by me. Can change my password to a temporary one and share with you, Matt. |
@Matt-Yorkley I'm wondering if there is not some common problem also below this issue #2739 (comment), I found that behavior super strange, seems like a big breach in our app... and also #2756 (comment). I don't know it feels to me like if all those issues could be connected... @OliverUK did this start just after you were added as a manager to a new enterprise? Or created a new enterprise? Do you have any clue of things you've done just before it starts bugging? |
@Matt-Yorkley and maybe also this: #2799 Nick made me manager of a new enterprise on 13th September but there is a good week between that and the above. It's closer to the v1.20 release. I'm glad no one else has reported this. I'm happy to let you log in as me and see what happens. |
@Matt-Yorkley have sent you my password on Slack |
Okay, I've tried with Oliver's login, and I can reproduce the bug with that. I get the 422 error. So a permissions issue makes the most sense, if I can save on one account and not on another. Bugsnag is giving me nothing, and the production log is also giving me nothing... |
@kristinalim maybe you can have a look as well. I'm looking in the Production log from failed update "422" error: It looks like the |
Was anything that touches permissions recently merged to master? This appears in v1.20. |
@HugsDaniel just did some tests and found strange permission bugs on can instance, seems all the s2 and some s3 bugs could be linked to a same permission issue. |
@myriamboure I definitely think they are all related! |
This doesn't appear to be the case in Can instance |
@Matt-Yorkley This could be misleading because an incomplete save continues to save other changes: #2776 |
But if I can save with one account with no errors, but on another account I get the 422, we can assume the product data that's being saved is ok, right? |
@Matt-Yorkley Yes, you're right. |
The redirect to |
Also, the angular controller looks like it should be passing |
@kristinalim Looks like the initial POST request is fine, but the subsequent redirect to the API route is what returns the 422, with this: |
@Matt-Yorkley I'm on it now too. Getting the same error in the console when running this: u = Spree::User.find_by_email("[email protected]")
products = OpenFoodNetwork::Permissions.new(u).editable_products.merge(Spree::Product.not_deleted).order('created_at DESC').ransack({}).result.page(1).per(500)
json_object = ActiveModel::ArraySerializer.new(products, each_serializer: Api::Admin::ProductSerializer)
json_object.to_json |
Nice detective work, @Matt-Yorkley. So it's |
I submitted PR #2831 which should address this. Sorry I was looking at the wrong places. 🙁 HTTP 422 is normally used when submitted data could not be processed, and the error was happening in a separate read-only request that did not indicate the error in the logs. |
UK have deployed this patch to prod and can confirm that the issues we've been experiencing have been fixed. Thanks humble superheros! |
Thank you guys!! Well done indeed. |
Description
In UK production site, in spree. Click save on the product page and you see an error message when infact the request has been processed. This is not the intended flow, instead you should see a saved/complete notification.
Expected Behavior
You should seed a "saved" notification when you click save and not 'Saving failed.Save failed due to invalid data:422'. This should only show when there is an error.
Actual Behavior
You click save and Saving failed.Save failed due to invalid data:422 comes up
Steps to Reproduce
Animated Gif/Screenshot
Context
Users will be confused and this there is an error when there is not. this will result in more support requests
Severity
Your Environment
UK production was upgraded to 1.20.0 today (24/09) and this issue is new as of today.
Possible Fix
Have the correct message when a task is successfully completed, and error show up only when there is an error.
The text was updated successfully, but these errors were encountered: