Openfoodnetwork: 500 Error on Payment Methods Report

Created on 9 Jun 2020  路  7Comments  路  Source: openfoodfoundation/openfoodnetwork

Description



The Order Cycle Management -> Payments Methods report loads all orders before even loading the filter/search page.

To find Payments Methods it uses a line:
pm = o.payments.first.payment_method -> payment.first is nil

If ONE order that is available to the user from ANY of their enterprises fails to find a payment method then the whole page crashes - 500Error:
undefined methodpayment_method' for nil:NilClass`

Bugsnag: https://app.bugsnag.com/yaycode/openfoodnetwork-uk/errors/5ea17c7622a1830018e1f834?filters[event.since][0]=30d&filters[error.status][0]=open

Since the system allows an order without a payment (?) we need this report to run regardless.

Expected Behavior


The report, ya know, works.

Actual Behaviour


SLUG

Steps to Reproduce




I have not been able to track down the enterprise that this order is associated with yet - but ther user [email protected] is associated with it. This user is the one I use for all reports integrations.

  1. Logged in as a user associated with an order without a payment
  2. Go to Payment Methods report
  3. Slug! (500 error)

Animated Gif/Screenshot


Workaround

Severity


bug-s2: a non-critical feature is broken, no workaround

Your Environment

  • Version used: 2.10.0
  • Browser name and version:
  • Operating System and version (desktop or mobile):

Possible Fix

From @luisramos0 on Slack:
Should be very easy to address (like this o.payments.first&.payment_method)

bug-s2

All 7 comments

@kirstenalarsen Well what I understand is that in @lin-d-hop 's case it's a super user that has the problem and not one enterprise in particular, which makes it difficult to find the order causing this.

That's the difference I see between the two. But maybe I've missunderstood.

Definitely not related to #4977.

Payment Totals report is not the Order Cycle Management -> Payment Methods report.

@lin-d-hop it's not the same report, but I think it is the same cause: some corrupt data.

Could well be related and due to an order not having a payment associated:
From Payments Report code ->
payments.first.payment_method.name

The key difference is that the data is loaded before the page renders so the corrupted order makes the page totally unusable for any user associated with the order.

Hey team, I'm hoping this can get into the next release please?

It made it to test ready so it should be tested by today or tomorrow

Was this page helpful?
0 / 5 - 0 ratings