Remus Avram Posted April 12, 2017 Report Share Posted April 12, 2017 Hi Ftrack, I try to create a simple note using this example: http://ftrack-python-api.rtd.ftrack.com/en/latest/example/note.html note_category = session.query("NoteCategory where name is '{0}'".format(category_name)) user = self._session.query('User where username is "{0}"'.format(username)) note = session.create("Note", { 'category': note_category, 'content': content, 'author': user } ) session.commit() Returns: ftrack_api.session.Session> ERROR | 2017/04/12 19:46:56.957 (MainThread)|Server reported error: IntegrityError(A note message must have recipients.) File ".../python-packages/ftrack-python-api/1.0.4/centos-6_x86-64/lib/python2.7/site-packages/ftrack_python_api-1.0.4-py2.7.egg/ftrack_api/session.py", line 1525, in _call File ".../python-packages/ftrack-python-api/1.0.4/centos-6_x86-64/lib/python2.7/site-packages/ftrack_python_api-1.0.4-py2.7.egg/ftrack_api/session.py", line 1157, in commit File "<stdin>", line 1, in <module> File ".../python/2.7/centos-6_x86-64/lib/python2.7/pdb.py", line 234, in default *** ServerError: Server reported error: IntegrityError(A note message must have recipients.) Best! Link to comment Share on other sites More sharing options...
Mattias Lagergren Posted April 13, 2017 Report Share Posted April 13, 2017 Hi Remus, There is a part of the article that you're referring to that is using the create_note help function on a task. And to see what it does you can refer to the source code of the CreateNoteMixin: https://bitbucket.org/ftrack/ftrack-python-api/src/bc3ca08a7692c58f0b5d9f5b658f5d59397a641c/source/ftrack_api/entity/note.py?at=master&fileviewer=file-view-default#note.py-36 For this specific error it looks like you do not have a parent_id in the note dictionary, which means that it will be sent as a message - and messages must have recipients. In the linked source code you can see how recipients are created. Link to comment Share on other sites More sharing options...
Remus Avram Posted April 13, 2017 Author Report Share Posted April 13, 2017 This is the documentation part which I am referring: You can also set the category when creating a note manually: category = session.query( 'NoteCategory where name is "External Note"' ).first() note = session.create('Note', { 'content': 'New note with external category', 'author': user, 'category': category }) task['notes'].append(note) If I create the note like in the above example, I get the respective error. Link to comment Share on other sites More sharing options...
Mattias Lagergren Posted April 13, 2017 Report Share Posted April 13, 2017 Strange, I run this code on a random task and user and I do not have that issue. If you go to the task in the web interface and click to create a note, then click on the recipients icon. Is it then pre-populated with recipients? Link to comment Share on other sites More sharing options...
Remus Avram Posted April 13, 2017 Author Report Share Posted April 13, 2017 I found the issue. Actually what I was trying to do is to create the note without adding it to the task before committing. category = session.query( 'NoteCategory where name is "External Note"' ).first() note = session.create('Note', { 'content': 'New note with external category', 'author': user, 'category': category }) session.commit() Link to comment Share on other sites More sharing options...
Mattias Lagergren Posted April 13, 2017 Report Share Posted April 13, 2017 Great, that explains the issue! Link to comment Share on other sites More sharing options...
Tilt Posted November 14, 2018 Report Share Posted November 14, 2018 Sorry to hijack this thread, but we're currently experiencing the same exception (IntegrityError(A note message must have recipients)). However, I'm not creating a note entity myself, I'm using .create_note on an AssetVersion or a Shot entity. Unfortunately, it pops up only now and then in an action handler so it's hard to debug. When I restart the event hub it works perfectly, when I call the event handler as a stand-alone python script after that error has happened everything works fine. So the only thing I was able to do until now was print lots of debugging output. Before the note gets created, the session isn't new but it doesn't have any pending operations (session.created/modified/deleted are empty according to my logs). The note gets created on an AssetVersion using create_note(). I supply an author and a category. Next, I set metadata on the newly created note and I modify its date (my code transfers notes from a client's Shotgun to our ftrack.) The session's operations are now: created: [<dynamic ftrack Note object 49129808>, <dynamic ftrack Metadata object 49129104>], modified: [<dynamic ftrack AssetVersion object 37916368>], deleted: [] Then the commit happens which sometimes throws that IntegrityError. In the exception handler I've done some digging around to figure out if that note object differs from other newly created notes where the exception doesn't occur. The only thing I've noticed is that parent_id and parent_type of that new note are "NOT SET" even though the new note object is part of the asset versions's ["notes"] list. Could that be the reason? The weird thing is that like I said it's hard to debug. Restarting the script so it gets a new session and re-running the whole thing has always fixed things so far. Link to comment Share on other sites More sharing options...
Mattias Lagergren Posted November 27, 2018 Report Share Posted November 27, 2018 Thank you for reaching out Tilt, one thing to help us debug this is if you could wrap you problematic statements in a try-except block and print some variables. I'd like to understand if this is a problem in the api client, backend or something related to the Shot/AssetVersion configuration: try: ... except: print asset_version['link'] # Or print shot['link'] or others raise When you know the entity you could re-run the action to see if you got the same issue. And then work backwards from that. Another idea is to see what happens if you run the action on a Shot that has not been saved in your Tasks spreadsheet. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.