stripe-node
stripe-node copied to clipboard
Why is `status` nullable on `Invoice` type?
The API docs do not indicate that it should be possible for an invoice to have a null status, but the typings indicate that this is possibe:
https://stripe.com/docs/api/invoices/object#invoice_object-status https://github.com/stripe/stripe-node/blob/09e0dcc60a8e3f5cae81b4f3c8681861fa2a6781/types/2020-08-27/Invoices.d.ts#L136
Golang SDK for comparison does not indicate nullable field:
https://github.com/stripe/stripe-go/blob/f6bb33dadf1663caa8b2757abe32357c443f2c51/invoice.go#L784
Same question for Subscription item quantity.
(sorry didn't mean to update the labels)
Hi @DanielNorris-at, sorry for the very late response!
These types are generated based on our OpenAPI spec (which is also generated based on our internal API definitions), and invoice.status is defined as nullable there. I've checked with the team that owns Invoices and have confirmed that invoice.status can indeed be null in some cases if we can't determine the invoice's state.
The API Ref doesn't have a consistent way to indicate whether a field will can be null or not. Some field definitions have explanations for when a field can be null, but this is up to the person writing the description and not enforced. We also have the example resources next to the field descriptions in the API Ref, and some of the fields are set to null there, but not indicated in the description (for example, invoice.receipt_number), or are not null there but can be, as in this case.
stripe-go also does not have a way to indicate whether a field is nullable or not. Can you give an example of what you expect to see if a field is nullable?
I haven't checked with the team that owns Subscriptions, but I suspect there are similarly edge cases where subscription_item.quantity is not set.
If you have integration or documentation questions, please reach out to support. Hope that helps! Closing this issue out as this is not a bug with the stripe-node library itself.
Thanks for the explanation @yejia-stripe!