fix update_data: PUT only changed fields, not the whole entity

PUTting the full entity dict back to data/entities/{id} sends server-managed
fields (id, created_at, updated_at, project_id, entity_type_id, ...) that
newer Kitsu rejects with ParameterException. Build a partial payload with
only name/description/nb_frames/data — and only fetch/merge existing data
when the caller is actually updating custom_data.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Joseph HENRY 2026-05-27 17:11:05 +02:00
parent 6b06224f8c
commit 01fccc63d9

View File

@ -415,27 +415,28 @@ class Kitsu(Tracker):
def update_data(self, entity, custom_data={}, name=None, description=None, frames=None, clear=False): def update_data(self, entity, custom_data={}, name=None, description=None, frames=None, clear=False):
if isinstance(entity, dict): if isinstance(entity, dict):
entity_id = entity['id'] entity_id = entity['id']
existing_data = entity.get('data') or {}
else: else:
entity_id = self.get_id(entity) entity_id = self.get_id(entity)
entity = gazu.client.fetch_one('entities', entity_id) existing_data = None
payload = {}
if name: if name:
entity['name'] = name payload['name'] = name
if description: if description:
entity['description'] = description payload['description'] = description
if frames: if frames:
entity['nb_frames'] = frames payload['nb_frames'] = frames
if clear or not entity['data']: if custom_data or clear:
entity['data'] = custom_data if clear:
else: payload['data'] = dict(custom_data)
entity['data'].update(custom_data) else:
if existing_data is None:
existing_data = gazu.client.fetch_one('entities', entity_id).get('data') or {}
payload['data'] = {**existing_data, **custom_data}
#print('######UPDATE DATA') entity_data = gazu.client.put(f"data/entities/{entity_id}", payload)
#pprint(entity)
entity_data = gazu.client.put(f"data/entities/{entity_id}", entity)
#print()
#pprint(entity)
return entity_data['data'] return entity_data['data']