Skip to content

Error when accessing invoice.lines.data's item.subscription_item if the item is not a subscription item. #1459

Description

@gazalamuhamed-finn

Describe the bug

When accessing item.subscription_item, I expect a None value but instead I get an Exception.

To Reproduce

stripe_invoice = stripe_repo.retrieve_stripe_invoice(existing_stripe_subscription.latest_invoice)
for item in stripe_invoice.lines.data:
     if item.subscription_item: # this throws an error if the item is not a subscription_item
        pass

Expected behavior

The expectation is that defaults to None if not a subscription_item.

(variable) subscription_item: ExpandableField[SubscriptionItem] | None
The subscription item that generated this line item. Left empty if the line item is not an explicit result of a subscription.

Code snippets

OS

macOS

Language version

Python 3.12.8

Library version

stripe 11.5.0

API version

2025-01-27.acacia

Additional context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions