contentful / contentful.py

Python client for the Contentful Content Delivery API https://www.contentful.com/developers/documentation/content-delivery-api/
MIT License
45 stars 39 forks source link

Fields with same names overwrite Entry attribute values and types (e.g. content_types) #77

Closed Obi-L closed 2 years ago

Obi-L commented 2 years ago

If a Contentful field shares the name of an internal class, retrieving the attribute from Entry that is meant to return that corresponding object Type returns instead the values of that Contentful field. Specifically, if a field in Contentful is named "Content Type", getting Entry.content_type returns the value of that field -- usually a str or int -- instead of the expected ContentType object. No error or warning seems to be triggered.

This name collision may apply to other internal classes as well, e.g. Entry, Asset, etc. Other spellings may also trigger this issue ("ContentType", content_type", etc.). I have not been able to test these.

This may be related to the open issue here: #73

rubydog commented 2 years ago

@Obi-L There are some reserved words in the library that cannot be used as field names. content_type is one of them.

It is not related to #73.

Obi-L commented 2 years ago

@rubydog Thank you for the reply. Are these reserved words specific to the Python client, or are they reserved for the Contentful API in general? How can a developer know what these reserved words are -- there doesn't seem to be any error message or warning raised.