feat: get plan bulk with cache#45
Conversation
🤖 Augment PR SummarySummary: Adds a cached bulk subscription-plan fetch path to reduce Billing API load in batch scenarios. Changes:
Technical Notes: Cached values are JSON-serialized plan dicts and re-validated via Pydantic 🤖 Was this summary useful? React with 👍 or 👎 |
| logger.exception( | ||
| "get_plan_bulk: failed to validate subscription plan for tenant(%s)", tenant_id | ||
| ) | ||
| results[tenant_id] = None |
There was a problem hiding this comment.
get_plan_bulk() is annotated/documented to return SubscriptionPlan values, but on validation failure it stores None in results which can break callers that assume a dict with plan/expiration_date (and it also diverges from the new unit test expectation of “skip invalid tenant”). Consider making the invalid-tenant behavior consistent (either skip, or change typing/consumers to explicitly handle None).
Other Locations
api/services/billing_service.py:366api/services/billing_service.py:376
🤖 Was this useful? React with 👍 or 👎
| assert len(result) == 2 | ||
| assert "tenant-valid-1" in result | ||
| assert "tenant-valid-2" in result | ||
| assert "tenant-invalid" not in result |
There was a problem hiding this comment.
This test expects the invalid tenant to be omitted ("tenant-invalid" not in result), but the current get_plan_bulk() implementation adds the key with a None value on validation failure, so this will fail. Consider aligning the test with the intended behavior (skip vs None).
🤖 Was this useful? React with 👍 or 👎
Benchmark PR from qodo-benchmark#445