Jump to content

Fail when try to delete Asset

Andrea Perisano

Recommended Posts

I found a curious issue when I try to delete an asset on web UI on ftrack.

I created an asset called "My asset2" via API

If I delete this asset on web interface and so I try to recreate that asset via API I get this error:


Server reported error: IntegrityError((MySQLdb._exceptions.IntegrityError) (1062, "Duplicate entry '44eaaa18-4164-11df-9218-0019bb4983d8-My asset2-e5ff307e-b7ee-11e' for key 'asset_Asset.typeid_key'") [SQL: u'INSERT INTO asset (id, name, context_id, taskid, type_id) VALUES (%s, %s, %s, %s, %s)'] [parameters: (u'f3c012b8-289e-49bb-82bf-3c0d0a1e63c5', 'My asset2', u'e5ff307e-b7ee-11eb-82d3-5aa2595ee477', None, u'44eaaa18-4164-11df-9218-0019bb4983d8')] (Background on this error at: http://sqlalche.me/e/gkpj))
NoneType: None


It looks like that asset still lives inside the task and I can't do anything to remove definitely, the only way to do that is to destroy the assetbuild...


Anyone notice this problem?

Link to comment
Share on other sites

Hi Andrea,


If you queried for the Asset, you would find that it still exists. What you deleted on the web UI was only an AssetVersion, and we do not also clean up Assets once their last AssetVersion is deleted. So, one solution is to use session.ensure() instead of session.create(). For example:

asset = session.ensure(
        'name': 'Asset',
        'context_id': folder['id'],
        'type_id': asset_type['id'],

At the moment, ensure() creates a query naively, so you must not use entity relations (i.e. set "context_id" and "type_id" instead of "context" and "type").


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...