FTS traceback when file size in extracted metadata is the wrong type
2017-02-20 11:07:42-0600 [-] [Failure instance: Traceback: <type 'exceptions.TypeError'>: %d format: a number is required, not unicode /grid/fermiapp/products/common/prd/twisted/v15_2_1/Linux64bit-2-6-2-12/lib/python/twisted/internet/defer.py:434:errback /grid/fermiapp/products/common/prd/twisted/v15_2_1/Linux64bit-2-6-2-12/lib/python/twisted/internet/defer.py:501:_startRunCallbacks /grid/fermiapp/products/common/prd/twisted/v15_2_1/Linux64bit-2-6-2-12/lib/python/twisted/internet/defer.py:588:_runCallbacks /grid/fermiapp/products/common/prd/twisted/v15_2_1/Linux64bit-2-6-2-12/lib/python/twisted/internet/defer.py:1184:gotResult --- <exception caught here> --- /grid/fermiapp/products/common/prd/twisted/v15_2_1/Linux64bit-2-6-2-12/lib/python/twisted/internet/defer.py:1126:_inlineCallbacks /grid/fermiapp/products/common/prd/twisted/v15_2_1/Linux64bit-2-6-2-12/lib/python/twisted/python/failure.py:389:throwExceptionIntoGenerator /grid/fermiapp/products/common/prd/FileTransferService/v5_0_1/NULL/python/fts/filestate.py:931:_noMD /grid/fermiapp/products/common/prd/twisted/v15_2_1/Linux64bit-2-6-2-12/lib/python/twisted/internet/defer.py:1128:_inlineCallbacks /grid/fermiapp/products/common/prd/FileTransferService/v5_0_1/NULL/python/fts/metadata.py:52:extractMetadata ]
Looks like this is probably triggering fts/metadata.py:51
if 'file_size' in md: if md['file_size'] != filestate.getFileSize(): raise InvalidMetadata("Metadata for '%s' says size is %d, but actual size is %d" %( filestate.getFileName(), md['file_size'], filestate.getFileSize()))
'cause the md['file_size'] is a string, not an int..
#1 Updated by Robert Illingworth almost 4 years ago
- Subject changed from FTS raises an exception when trying to raise an exception... to FTS traceback when file size in extracted metadata is the wrong type
md['file_size'] is supposed to be a int or long, so I blame the user. But I think an explicit type check is a more user-friendly way of enforcing this. Or maybe we should just accept anything convertible to a long (I think samweb does this when you give it the metadata).
(It's not really raising an exception while raising an exception - that's just how twisted reports exceptions from deferred object invocation. Exceptions aren't really compatible with asynchronous callback style.)