Skip to content

Nutrition Response cast to the wrong type in the Union #61

Description

@jcelmeta14

Hey all!

So I am using the Nutrition api. The type of the Response is defined as a Union:

NutritionFetchResponse = typing.Union[
    NutritionFetchResponseData,
    NoDataReturned,
    DataSentToWebhook,
    RequestProcessing,
    RateLimitRequestProcessing,
    LargeRequestProcessingEvent,
]

For my request, I am setting only the start_date to some ISO date str, and the to_webhook to False because I wanted to get some data back immediately. For this request configuration I am expecting to get back a NutritionFetchResponseData that is part of the union. Oddly enough i am getting back a NoDataResponse even though the data parameter is defined and it actually has some nutrition information. Here's a screenshot of the debugger:

Image

As you can see the data field is part of the mode_extra which is weird. The response type should be NutritionFetchResponseData and the fields should be normally part of the model instance.

It might very well be something I am doing that is wrong, although I am not doing too much.

Thank you for your support,
J

Activity

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

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