Skip to content

Commit

Permalink
handle more permid decode errors
Browse files Browse the repository at this point in the history
  • Loading branch information
pudo committed Aug 28, 2024
1 parent c58bf25 commit 9535e03
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions nomenklatura/enrich/permid.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,12 @@ def fetch_permid(self, url: str) -> Optional[Dict[str, Any]]:
params = {"format": "json-ld"}
hidden = {"access-token": self.api_token}
res_raw = self.http_get_cached(url, params=params, hidden=hidden, cache_days=90)
if not len(res_raw):
try:
return cast(Dict[str, Any], json.loads(res_raw))
except Exception:
log.info("Invalid response from PermID: %s", url)
self.http_remove_cache(url, params=params)
log.info("Empty response from PermID: %s", url)
return None
return cast(Dict[str, Any], json.loads(res_raw))

def fetch_perm_org(self, entity: CE, url: str) -> Optional[CE]:
res = self.fetch_permid(url)
Expand Down

0 comments on commit 9535e03

Please sign in to comment.