Skip to content

[BUG]: CustomerUsageResponse.invoice_id is never populated — API returns lago_invoice_id #407

Description

@ayush-sharaf

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

  1. Call client.customers().past_usage(external_customer_id, external_subscription_id) for a customer with closed billing periods (each of which has an invoice).
  2. Inspect any element of usage_periods.
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions