IndexError in BasketSummaryView - line.has_discount vs. basket.applied_offers

Description

We hit this "list index out of range" error recently in BasketSummaryView._process_basket_lines, but the offending line of code has not been touched in 2 years. The logic assumes that if a basket line's has_discount property is true then it's applied_offers() will have at least on item. The OpsGenie alert for this was only a a P1 because the 12 occurrences of this constituted a significant percentage of all requests over a 5 minute period.

the offending line:
https://github.com/edx/ecommerce/blame/ee7e9d1c1daa746f53bfb60a6babac4c3e59cdec/ecommerce/extensions/basket/views.py#L286

the OpsGenie alert:
https://app.opsgenie.com/alert#/show/c3c8e35b-a775-4e9b-aaf5-f09333d93dc2-1537726615656/details

the NewRelic link
https://rpm.newrelic.com/accounts/88178/applications/5519285/filterable_errors#/table?top_facet=transactionUiName&barchart=barchart

Steps to Reproduce

None

Current Behavior

None

Expected Behavior

None

Reason for Variance

None

Release Notes

None

User Impact Summary

None

Status

Assignee

Unassigned

Reporter

Jason Myatt

Labels

Reach

None

Impact

None

Customer

None

Partner Manager

None

URL

None

Contributor Name

None

Groups with Read-Only Access

None

Actual Points

None

Category of Work

None

Stakeholders

None

Priority

Unset
Configure