Closed EricNelson12 closed 2 years ago
Accidentally created this for ruby instead of python. See https://github.com/contentful/contentful.py/issues/74 for the story of how I was tricked by a button :laughing:
And link to the python version of this issue:
Since
ContentTypeCache
has a static field__CACHE__ = []
, this__CACHE__
object is reused across clients.ContentTypeCache
's methodsget
andupdate_cache
are called statically instead of on different instances ofContentTypeCache
So if I have two spaces, and need two clients like
When
update_cache
is called for the second client, it will replace the cache made by the first client.This might go undetected if the spaces have difference content type ids or content types with different field names. But if the spaces have the same content type ids, then when the cache is called like:
It will happily return a content type which might not have the same field type. This causes errors if for example, it expects a dict, but instead gets a string type.
So either new instances of
ContentTypeCache
should be created per client, or the key to__CACHE__
should be prefixed with the space id.Thanks for reading!