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

[API] empty cart endpoint raises 500 error with shipped order #4438

Open
spaghetticode opened this issue Jun 22, 2022 · 2 comments · May be fixed by #5418
Open

[API] empty cart endpoint raises 500 error with shipped order #4438

spaghetticode opened this issue Jun 22, 2022 · 2 comments · May be fixed by #5418
Labels
good first issue Wanted, but lacking time to work on it and might be a good fit for a first contribution type:bug Error, flaw or fault

Comments

@spaghetticode
Copy link
Member

Solidus Version:
all, including master

How to reproduce
Trying to empty a shipped order via API raises a 500 error, which is something we should try to avoid.

This can be easily demonstrated in the admin area:

  • on the Cart tab, add an item to a new order, and keep this browser window as it is, we'll get back to it later;
  • add the address, payment, and finalize the order in a different browser window/tab;
  • ship the order;
  • go back to the Cart browser window and click the Empty Cart button. Web developer tools will show a 500 error, and no message is presented to the user.

Context

This is the method definition from the API orders controller:

      def empty
        authorize! :update, @order, order_token
        @order.empty!
        render plain: nil, status: 204
      end

@order.empty! tries to reset the cart by destroying the associated records, but shipped shipments cannot be destroyed. The error bubbles up to the controller, where it's not handled.
Screen Shot 2022-06-22 at 11 18 08 AM

@kennyadsl kennyadsl added type:bug Error, flaw or fault good first issue Wanted, but lacking time to work on it and might be a good fit for a first contribution labels Aug 29, 2022
@dborovsky
Copy link

dborovsky commented Aug 30, 2022

Hi @kennyadsl @spaghetticode I'll investigate and fix it.

@nirnaeth nirnaeth linked a pull request Oct 4, 2023 that will close this issue
4 tasks
@nirnaeth
Copy link
Contributor

nirnaeth commented Oct 4, 2023

I have issued a PR to fix the problem. Code works, but I need advise on the test and on how to redirect properly to the order

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Wanted, but lacking time to work on it and might be a good fit for a first contribution type:bug Error, flaw or fault
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants