Filter out invoices that do not have a subscription attached to the invoice
Product Description
Technical Summary
https://dimagi.atlassian.net/browse/SAAS-15321
Meant to serve as the smallest change necessary to get past the immediate error encountered when finding accounts to downgrade. https://dimagi.sentry.io/issues/3574964056/?project=136860
Feature Flag
Safety Assurance
Safety story
This is only run in the periodic task to find eligible domains to downgrade. This change is safe because it just adds logic to prevent an exception from being raised when trying to access the "plan_version" attribute on a None type.
Automated test coverage
Not that I'm aware of.
QA Plan
None
Rollback instructions
- [x] This PR can be reverted after deploy with no further considerations
Labels & Review
- [x] Risk label is set correctly
- [x] The set of people pinged as reviewers is appropriate for the level of risk of the change
Hi Graham, I'm wondering, without the try catch, how can we get alerted for the similar issue in the future? I thought if we want to downgrade a subscription and cannot do so, there should be a way to notify us that something happens for that subscription?
The philosophy would be that we want the task to fail hard since that is the "best" way to get alerted about it (the relevant celery task will consistently fail and we will be alerted about that in datadog). The reason this slipped through the cracks previously is because we didn't have that alert setup. There is something to be said for a more durable task that can handle failures, but I also feel like the best way we have of getting alerted of failures is via datadog alerts, not sentry errors.
@jingcheng16 made a good point that I should at least log the skipped accounts that have funky invoices not attached to subscriptions. So I can make that change, but also noting that this task is currently not failing, so before moving forward with this PR we want to understand that better. I don't have the time to look into this right now so dropping for now.
Closing in hopes that https://github.com/dimagi/commcare-hq/pull/36168 can get pushed over the finish line!