From 56732f21d49a30048a713c554a12c9b04f0dd151 Mon Sep 17 00:00:00 2001 From: Christophe Haen Date: Mon, 11 Dec 2023 14:12:26 +0100 Subject: [PATCH] fix (WLCG Json accounting): make sure the file we download is json --- .../Storage/OccupancyPlugins/WLCGAccountingJson.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/DIRAC/Resources/Storage/OccupancyPlugins/WLCGAccountingJson.py b/src/DIRAC/Resources/Storage/OccupancyPlugins/WLCGAccountingJson.py index 112168c3484..30e794b046a 100644 --- a/src/DIRAC/Resources/Storage/OccupancyPlugins/WLCGAccountingJson.py +++ b/src/DIRAC/Resources/Storage/OccupancyPlugins/WLCGAccountingJson.py @@ -44,6 +44,10 @@ def _downloadJsonFile(self, occupancyLFN, filePath): continue occupancyURL = res["Value"] ctx.filecopy(params, occupancyURL, "file://" + filePath) + # Just make sure the file is json, and not SSO HTML + with open(filePath) as f: + json.load(f) + return except gfal2.GError as e: detailMsg = "Failed to copy file %s to destination url %s: [%d] %s" % ( @@ -54,6 +58,9 @@ def _downloadJsonFile(self, occupancyLFN, filePath): ) self.log.debug("Exception while copying", detailMsg) continue + except json.decoder.JSONDecodeError as e: + self.log.debug("Downloaded file is not json") + continue def getOccupancy(self, **kwargs): """Returns the space information given by WLCG Accouting Json