Skip to content

[Bug]: InvoiceItem.UnitPrice is a string #848

@jwhited

Description

@jwhited

go Version

go version 1.25.3

API Wrapper Version

github.com/linode/linodego v1.61.0

Code Snippet

linodeClient := linodego.NewClient(oauth2Client)
	linodeClient.SetDebug(true)
	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
	invoices, err := linodeClient.ListInvoices(ctx, &linodego.ListOptions{})
	cancel()
	if err != nil {
		log.Fatalf("error listing invoices: %v", err)
	}
	for _, invoice := range invoices {
		ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
		items, err := linodeClient.ListInvoiceItems(ctx, invoice.ID, &linodego.ListOptions{})
		cancel()
		if err != nil {
			log.Fatalf("error listing invoice items: %v", err)
		}
		log.Printf("invoice: %v %d", invoice.Date, invoice.ID)
		for _, item := range items {
			log.Printf("%+v", item)
		}
	}

Expected Behavior

items are printed, no errors

Actual Behavior

      {
         "label": "<redacted>",
         "unit_price": "0",
         "amount": 0.0,
         "quantity": 82,
         "tax": 0.0,
         "total": 0.0,
         "from": "2025-07-23T13:07:15",
         "to": "2025-07-26T22:08:01",
         "type": "hourly",
         "region": "br-gru"
      }

fails to unmarshal:

error listing invoice items: [002] json: cannot unmarshal string into Go struct field paginatedResponse[github.com/linode/linodego.InvoiceItem].data.Mask.unit_price of type float32

Steps to Reproduce

see code block

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugissues that report a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions