Repository: dmwm/wmcore
Issue: DBS3Upload not properly parsing error messages for blocks already inserted

**Impact of the bug**
WMAgent

**Describe the bug**
While validating the latest candidate WMAgent release: 1.5.7, I noticed that DBS3Upload is failing to identify that a given block has already been inserted into DBS server, thus retrying to insert that same block infinitely. Error code can be found at [1]

**How to reproduce it**
Mark an already inserted block as not in DBS, such that DBS3Upload will attempt to insert it in the next cycle.

**Expected behavior**
DBS3Upload component should parse the HTTP response object and properly identify that that block has already been inserted into DBS server, thus proceeding with the normal workflow of block injection into the server (marking that block as inserted in the relational database).

**Additional context and error message**
[1]
```
2022-01-26 21:54:51,636:139908283959040:INFO:DBSUploadPoller:About to insert block /RelValProdMinBias/Agent157_Val-Agent157_Val_OLD_Alanv3-v22/GEN-SIM#5927f844-ecd8-4a18-9eca-3f4a1a37567f
2022-01-26 21:54:51,702:139908283959040:ERROR:DBSUploadPoller:Error trying to process block /RelValProdMinBias/Agent157_Val-Agent157_Val_OLD_Alanv3-v22/GEN-SIM#5927f844-ecd8-4a18-9eca-3f4a1a37567f through DBS. Error: HTTP Error 400: Bad R
equest
Traceback (most recent call last):
  File "/data/srv/wmagent/v1.5.7/sw/slc7_amd64_gcc630/cms/py3-dbs3-client/4.0.5/lib/python3.8/site-packages/dbs/apis/dbsClient.py", line 488, in __parseForException
    raise HTTPError(http_error.url, data['exception'], data['message'], http_error.header, http_error.body)
RestClient.ErrorHandling.RestClientExceptions.HTTPError: HTTP Error 400: DBSBlockInsert/insertBlock. Block /RelValProdMinBias/Agent157_Val-Agent157_Val_OLD_Alanv3-v22/GEN-SIM#5927f844-ecd8-4a18-9eca-3f4a1a37567f already exists.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/data/srv/wmagent/v1.5.7/sw/slc7_amd64_gcc630/cms/wmagentpy3/1.5.7/lib/python3.8/site-packages/WMComponent/DBS3Buffer/DBSUploadPoller.py", line 85, in uploadWorker
    dbsApi.insertBulkBlock(blockDump=block)
  File "/data/srv/wmagent/v1.5.7/sw/slc7_amd64_gcc630/cms/py3-dbs3-client/4.0.5/lib/python3.8/site-packages/dbs/apis/dbsClient.py", line 605, in insertBulkBlock
    result =  self.__callServer("bulkblocks", data=blockDump, callmethod='POST' )
  File "/data/srv/wmagent/v1.5.7/sw/slc7_amd64_gcc630/cms/py3-dbs3-client/4.0.5/lib/python3.8/site-packages/dbs/apis/dbsClient.py", line 448, in __callServer
    self.__parseForException(http_error)
  File "/data/srv/wmagent/v1.5.7/sw/slc7_amd64_gcc630/cms/py3-dbs3-client/4.0.5/lib/python3.8/site-packages/dbs/apis/dbsClient.py", line 490, in __parseForException
    raise http_error
  File "/data/srv/wmagent/v1.5.7/sw/slc7_amd64_gcc630/cms/py3-dbs3-client/4.0.5/lib/python3.8/site-packages/dbs/apis/dbsClient.py", line 445, in __callServer
    self.http_response = method_func(self.url, method, params, data, request_headers)
  File "/data/srv/wmagent/v1.5.7/sw/slc7_amd64_gcc630/cms/py3-dbs3-pycurl/3.17.7/lib/python3.8/site-packages/RestClient/RestApi.py", line 42, in post
    return http_request(self._curl)
  File "/data/srv/wmagent/v1.5.7/sw/slc7_amd64_gcc630/cms/py3-dbs3-pycurl/3.17.7/lib/python3.8/site-packages/RestClient/RequestHandling/HTTPRequest.py", line 62, in __call__
    raise HTTPError(effective_url, http_code, http_response.msg, http_response.raw_header, http_response.body)
RestClient.ErrorHandling.RestClientExceptions.HTTPError: HTTP Error 400: Bad Request
```

Changed files:
src/python/WMComponent/DBS3Buffer/DBSUploadPoller.py

diff --git a/src/python/WMComponent/DBS3Buffer/DBSUploadPoller.py b/src/python/WMComponent/DBS3Buffer/DBSUploadPoller.py
index 2e885339c..c9a1f8ed3 100644
--- a/src/python/WMComponent/DBS3Buffer/DBSUploadPoller.py
+++ b/src/python/WMComponent/DBS3Buffer/DBSUploadPoller.py
@@ -85,7 +85,7 @@ def uploadWorker(workInput, results, dbsUrl):
             dbsApi.insertBulkBlock(blockDump=block)
             results.put({'name': name, 'success': "uploaded"})
         except Exception as ex:
-            exString = str(ex)
+            exString = str(getattr(ex, "body", ex))
             if 'Block %s already exists' % name in exString:
                 # Then this is probably a duplicate
                 # Ignore this for now