From db82cff3e244763eb80bad0d4a2e0b54f5adf19d Mon Sep 17 00:00:00 2001 From: Raquel Smith Date: Thu, 16 Nov 2023 12:36:29 -0800 Subject: [PATCH] fix: tolerate missing rows_synced in billing response (#18695) * tolerate missing rows_synced * more fix --- ee/billing/billing_manager.py | 2 +- ee/billing/quota_limiting.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ee/billing/billing_manager.py b/ee/billing/billing_manager.py index a906f6796603e..5a8119c57df9b 100644 --- a/ee/billing/billing_manager.py +++ b/ee/billing/billing_manager.py @@ -225,7 +225,7 @@ def update_org_details(self, organization: Organization, billing_status: Billing usage_info = OrganizationUsageInfo( events=usage_summary["events"], recordings=usage_summary["recordings"], - rows_synced=usage_summary["rows_synced"], + rows_synced=usage_summary.get("rows_synced", None), period=[ data["billing_period"]["current_period_start"], data["billing_period"]["current_period_end"], diff --git a/ee/billing/quota_limiting.py b/ee/billing/quota_limiting.py index 0a6860d62769c..ef3e12a421575 100644 --- a/ee/billing/quota_limiting.py +++ b/ee/billing/quota_limiting.py @@ -74,6 +74,8 @@ def org_quota_limited_until(organization: Organization, resource: QuotaResource) return None summary = organization.usage.get(resource.value, {}) + if not summary: + return None usage = summary.get("usage", 0) todays_usage = summary.get("todays_usage", 0) limit = summary.get("limit") @@ -146,6 +148,8 @@ def set_org_usage_summary( for field in ["events", "recordings", "rows_synced"]: resource_usage = new_usage[field] # type: ignore + if not resource_usage: + continue if todays_usage: resource_usage["todays_usage"] = todays_usage[field] # type: ignore