OpenXbox / xbox-webapi-python

A python library to authenticate with Xbox Live via your Microsoft Account and provides Xbox related Web-API.
https://pypi.python.org/pypi/xbox-webapi
MIT License
178 stars 46 forks source link

Validation errors raised for valid response #40

Closed Landcross closed 3 years ago

Landcross commented 3 years ago

When I search the catalog for product ID 9P29XK3N9SVQ (Assassin’s Creed Valhalla + Watch Dogs: Legion Bundle) the following error is raised:

pydantic.error_wrappers.ValidationError: 2 validation errors for CatalogResponse
Products -> 0 -> ValidationData -> ValidationResultUri
  none is not an allowed value (type=type_error.none.not_allowed)
Products -> 0 -> DisplaySkuAvailabilities -> 0 -> Sku -> Properties -> FulfillmentType
  none is not an allowed value (type=type_error.none.not_allowed)

However, when inspecting the raw api response, it seems to work fine. So, I think the validations are a little too restricted for the above values.

Landcross commented 3 years ago

Another validation issue:

Products -> 0 -> DisplaySkuAvailabilities -> 0 -> Sku -> Properties -> Packages
  none is not an allowed value (type=type_error.none.not_allowed)
Landcross commented 3 years ago

Another validation issue:

Products -> 6 -> DisplaySkuAvailabilities -> 0 -> Sku -> MarketProperties -> 0 -> FirstAvailableDate
  none is not an allowed value (type=type_error.none.not_allowed)
Landcross commented 3 years ago

Sorry for the spam :( Found two more validation errors:

Products -> 1 -> DisplaySkuAvailabilities -> 0 -> Sku -> Properties -> FulfillmentData -> WuBundleId
  none is not an allowed value (type=type_error.none.not_allowed)
Products -> 1 -> DisplaySkuAvailabilities -> 0 -> Sku -> Properties -> BundledSkus
  none is not an allowed value (type=type_error.none.not_allowed)
Landcross commented 3 years ago

I found two more validation issues when running a search for 'Creed' in region 'Argentina':

Results -> 3 -> Products -> 0 -> Height
  field required (type=value_error.missing)
Results -> 3 -> Products -> 0 -> Width
  field required (type=value_error.missing)
Landcross commented 3 years ago

Some more 😅

pydantic.error_wrappers.ValidationError: 1 validation error for CatalogResponse
Products -> 0 -> DisplaySkuAvailabilities -> 0 -> Availabilities -> 1 -> OrderManagementData
  field required (type=value_error.missing)

pydantic.error_wrappers.ValidationError: 21 validation errors for CatalogSearchResponse
Results -> 1 -> Products -> 0 -> BackgroundColor
  field required (type=value_error.missing)
Results -> 1 -> Products -> 0 -> ImageType
  field required (type=value_error.missing)
Results -> 1 -> Products -> 0 -> Icon
Landcross commented 3 years ago
pydantic.error_wrappers.ValidationError: 2 validation errors for CatalogResponse
Products -> 0 -> MarketProperties -> 0 -> OriginalReleaseDate
  field required (type=value_error.missing)
Products -> 0 -> DisplaySkuAvailabilities -> 0 -> Sku -> MarketProperties -> 0 -> FirstAvailableDate
  invalid datetime format (type=value_error.datetime)

The FirstAvailableDate is an empty string in the error-case.

tuxuser commented 3 years ago

Thanks for your report, testing and detailed error messages. Could you send a PR?

Simply edit the fields to be Optional[type] but you probably know that already ;)

Landcross commented 3 years ago

Sure, it should be available now in #41 . I had modified the models.py file locally already anyway. I'm not exactly too familiar with pull-requests, so I hope it all went well :)