dbsReader listFilesInBlockWithParents crash on RAW : dataset with no parents
Whilte trying to bring https://github.com/CMSCompOps/WmAgentScripts/blob/master/recover/recoverMissingLumis.py to have parent info

Calling 

blockFileParents = dbsReader.listFilesInBlockWithParents(blockName)

one gets 

/DoubleEG/Run2015D-v1/RAW#fceb85c4-5ce3-11e5-824b-001e67ac06a0

Traceback (most recent call last):
  File "recover/recoverMissingLumis.py", line 666, in <module>
    sys.exit(main())
  File "recover/recoverMissingLumis.py", line 663, in main
    val.group, val.dbsUrl, val.fake, datasetInformation)
  File "recover/recoverMissingLumis.py", line 410, in defineRequests
    blockBlacklist, blockWhitelist, dbsUrl, fakeLocation=fakeLocation)
  File "recover/recoverMissingLumis.py", line 246, in getFiles
    blockFileParents = dbsReader.listFilesInBlockWithParents(blockName)
  File "/data/srv/wmagent/v1.0.17.pre4/sw/slc6_amd64_gcc493/cms/wmagent/1.0.17.pre4/lib/python2.7/site-packages/WMCore/Services/DBS/DBS3Reader.py", line 528, in listFilesInBlockWithParents
    parentLumis = self._getLumiList(lfns = parentsLFNs)
  File "/data/srv/wmagent/v1.0.17.pre4/sw/slc6_amd64_gcc493/cms/wmagent/1.0.17.pre4/lib/python2.7/site-packages/WMCore/Services/DBS/DBS3Reader.py", line 82, in _getLumiList
    for lumisItem in lumiLists:
UnboundLocalError: local variable 'lumiLists' referenced before assignment

admittedly, the block has no parent, it might not be a reason to crash.

diff --git a/src/python/WMCore/Services/DBS/DBS3Reader.py b/src/python/WMCore/Services/DBS/DBS3Reader.py
index 9b82361c1..6e372a889 100644
--- a/src/python/WMCore/Services/DBS/DBS3Reader.py
+++ b/src/python/WMCore/Services/DBS/DBS3Reader.py
@@ -74,6 +74,10 @@ class DBS3Reader:
                 lumiLists = []
                 for slfn in grouper(lfns, 50):
                     lumiLists.extend(self.dbs.listFileLumiArray(logical_file_name = slfn))
+            else:
+                # shouldn't call this with both blockName and lfns empty
+                # but still returns empty dict for that case
+                return {}
         except dbsClientException as ex:
             msg = "Error in "
             msg += "DBSReader.listFileLumiArray(%s)\\n" % lfns
@@ -531,7 +535,14 @@ class DBS3Reader:
             # Probably a child can have more than 1 parent file
             for fp in f['parent_logical_file_name']:
                 childByParents[fp].append(f['logical_file_name'])
+        
         parentsLFNs = childByParents.keys()
+        
+        if len(parentsLFNs) == 0:
+            msg = "Error in "
+            msg += "DBSReader.listFilesInBlockWithParents(%s)\\n There is no parents files" % (
+                fileBlockName)
+            raise DBSReaderError(msg)
 
         parentFilesDetail = []
         #TODO: slicing parentLFNs util DBS api is handling that.
['src/python/WMCore/Services/DBS/DBS3Reader.py']