Describe the bug
CustomerUsageResponse declares an invoice_id field, but the Lago API returns the invoice reference under the key lago_invoice_id (see the past usage API reference). Since pydantic ignores unknown keys, lago_invoice_id is silently dropped during parsing and invoice_id is always None.
As a result, usage periods returned by client.customers().past_usage(...) cannot be tied back to their invoices.
Your own test fixture confirms the key name — tests/fixtures/customer_past_usage.json contains "lago_invoice_id": "1a901a90-1a90-1a90-1a90-1a901a901a90" while the model (lago_python_client/models/customer_usage.py, line 76 on current main) declares invoice_id: Optional[str].
To Reproduce
- Call
client.customers().past_usage(external_customer_id, external_subscription_id) for a customer with closed billing periods (each of which has an invoice).
- Inspect any element of
usage_periods.
period.invoice_id is None even though the raw API response contains a lago_invoice_id for that period.
Expected behavior
The parsed usage period should expose the invoice id sent by the API (e.g. a lago_invoice_id field, as was done for WalletTransactionResponse in #379).
Support
- lago-python-client: 1.50.0 (still present on
main)
- Python: 3.13, pydantic 2.x (via the
pydantic.v1 shim)
Additional context
current_usage is affected the same way in principle, but there lago_invoice_id is documented as nullable anyway; for past_usage the dropped field is the only link between a closed period and its invoice.
Describe the bug
CustomerUsageResponsedeclares aninvoice_idfield, but the Lago API returns the invoice reference under the keylago_invoice_id(see the past usage API reference). Since pydantic ignores unknown keys,lago_invoice_idis silently dropped during parsing andinvoice_idis alwaysNone.As a result, usage periods returned by
client.customers().past_usage(...)cannot be tied back to their invoices.Your own test fixture confirms the key name —
tests/fixtures/customer_past_usage.jsoncontains"lago_invoice_id": "1a901a90-1a90-1a90-1a90-1a901a901a90"while the model (lago_python_client/models/customer_usage.py, line 76 on currentmain) declaresinvoice_id: Optional[str].To Reproduce
client.customers().past_usage(external_customer_id, external_subscription_id)for a customer with closed billing periods (each of which has an invoice).usage_periods.period.invoice_idisNoneeven though the raw API response contains alago_invoice_idfor that period.Expected behavior
The parsed usage period should expose the invoice id sent by the API (e.g. a
lago_invoice_idfield, as was done forWalletTransactionResponsein #379).Support
main)pydantic.v1shim)Additional context
current_usageis affected the same way in principle, but therelago_invoice_idis documented as nullable anyway; forpast_usagethe dropped field is the only link between a closed period and its invoice.