add more type checking for parsing object type from an object
authorDiane Trout <diane@caltech.edu>
Sat, 13 Dec 2014 00:34:30 +0000 (16:34 -0800)
committerDiane Trout <diane@caltech.edu>
Sat, 13 Dec 2014 00:34:30 +0000 (16:34 -0800)
htsworkflow/submission/encoded.py

index f38c039e56062402eb1517ef943b3671279ec1f0..30b691607e6c2b6d7f7c114f8ede0f364b64c1aa 100644 (file)
@@ -214,8 +214,13 @@ class ENCODED:
         """Return type for a encoded object
         """
         obj_type = obj.get('@type')
-        if obj_type and isinstance(obj_type, collections.Sequence):
-            return obj_type[0]
+        if not obj_type:
+            raise ValueError('None type')
+        if type(obj_type) in types.StringTypes:
+            raise ValueError('@type should be a list, not a string')
+        if not isinstance(obj_type, collections.Sequence):
+            raise ValueError('@type is not a sequence')
+        return obj_type[0]
 
     def get_schema_url(self, obj):
         obj_type = self.get_object_type(obj)