commcare-hq icon indicating copy to clipboard operation
commcare-hq copied to clipboard

Filter out invoices that do not have a subscription attached to the invoice

Open gherceg opened this issue 2 years ago • 3 comments

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

gherceg avatar Feb 26 '24 20:02 gherceg

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?

jingcheng16 avatar Feb 26 '24 21:02 jingcheng16

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.

gherceg avatar Feb 26 '24 21:02 gherceg

@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.

gherceg avatar Feb 29 '24 20:02 gherceg

Closing in hopes that https://github.com/dimagi/commcare-hq/pull/36168 can get pushed over the finish line!

gherceg avatar Apr 07 '25 20:04 gherceg