Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix(backend): Fix transaction history listing on older transaction with no metadata

Zamil Majdyf44453be6ead
diff --git a/autogpt_platform/backend/backend/data/credit.py b/autogpt_platform/backend/backend/data/credit.py
index ba2d0f4118..4048ffdfb1 100644
--- a/autogpt_platform/backend/backend/data/credit.py
+++ b/autogpt_platform/backend/backend/data/credit.py
@@ -504,7 +504,11 @@ class UserCredit(UserCreditBase):
)
tx_time = None
for t in transactions:
- metadata = UsageTransactionMetadata.model_validate(t.metadata)
+ metadata = (
+ UsageTransactionMetadata.model_validate(t.metadata)
+ if t.metadata
+ else UsageTransactionMetadata()
+ )
tx_time = t.createdAt.replace(tzinfo=None)
if t.type == CreditTransactionType.USAGE and metadata.graph_exec_id: