shotgun_api3.shotgun.ShotgunError: Could not upload file successfully, but not sure why

After rendering draft videos on our farm, we upload them to Shotgun.
On video upload, in rare cases, we get this error, and it baffles me:
shotgun_api3.shotgun.ShotgunError: Could not upload file successfully, but not sure why.
(stacktrace below)

The draft is part of a very automated process, so there cannot be significant differences between this one and the tens or hundreds of others that are successfully uploaded every day.

It seems like the response is empty?

This script uses a shared shotgun api (not the centralized one in the project), but I guess it does not matter in this case? The versions of the two match.


Stack trace

2020-05-13 14:41:45:  0: STDOUT:   File "\\DeadlineRepository10\custom\draft\draft_scripts\Bottleship_draft_master.py", line 451, in renderFrames
2020-05-13 14:41:45:  0: STDOUT:     outFile), 'sg_uploaded_movie')
2020-05-13 14:41:45:  0: STDOUT:   File "Z:/_pipeline/lib/btl_sg_lib\shotgun_api3\shotgun.py", line 2282, in upload
2020-05-13 14:41:45:  0: STDOUT:     tag_list, is_thumbnail)
2020-05-13 14:41:45:  0: STDOUT:   File "Z:/_pipeline/lib/btl_sg_lib\shotgun_api3\shotgun.py", line 2351, in _upload_to_storage
2020-05-13 14:41:45:  0: STDOUT:     path, url, str(result)))
2020-05-13 14:41:45:  0: STDOUT: shotgun_api3.shotgun.ShotgunError: Could not upload file successfully, but not sure why.
2020-05-13 14:41:45:  0: STDOUT: Path: -redacted-
2020-05-13 14:41:45:  0: STDOUT: Url: https://bottleship.shotgunstudio.com/upload/api_link_file
2020-05-13 14:41:45:  0: STDOUT: Error: 0
2020-05-13 14:41:45:  0: STDOUT: Value is not legal.

Any ideas are welcome.

That error message could certainly be better! Which version of the Python API are you using? If you’re not sure, you can run this to find out:

>> import shotgun_api3
>> shotgun_api3.__version__

I see Deadline mentioned in the error message, and depending on which release you’re using they may have an older version of the Shotgun API bundled with their integration that has the potential to cause unexpected issues. I’d recommend grabbing the latest release from GitHub.

I checked, and both versions are the same - commit_id e63f83a7799982850b28494df7cef813f7d232fd. It’s relatively recent, if not latest.

It is printed in the log that shotgun_api3 is coming from z:/_pipeline/lib/btl_sg_lib, which is the correct location. It might be the case that some underlying library is clashing, though, such as httplib or similar. How do I even diagnose that?

The error happens consistently on specific renders, but works for all others. The Deadline render job tries multiple times to render the file, then upload it, but fails each time.

All considered, it does not add up that this is happening so rarely. If there was a wrong lib in Deadline, wouldn’t that be hitting around half the renders?

That’s one possibility. One way to check would be to add some debug prints where the uploads are failing so we can see which modules are loaded, and from where (when it succeeds, and when it fails so we can compare the two):

import os, ssl, httplib

print(ssl._ssl.__file__)
print(httplib.__file__)
print(os.environ['PYTHONPATH'])
1 Like