Browse Source

fix(api): work around key retrieval failure

Without this fix, GET/POST on domains/ returns 404 because the
serializer cannot construct the keys field. This leads to error
messages during dynDNS signup.
Peter Thomassen 8 years ago
parent
commit
550649be09
1 changed files with 8 additions and 4 deletions
  1. 8 4
      api/desecapi/pdns.py

+ 8 - 4
api/desecapi/pdns.py

@@ -130,10 +130,14 @@ def get_keys(domain):
     """
     Retrieves a JSON representation of the DNSSEC key information
     """
-    r = _pdns_get('/zones/%s/cryptokeys' % domain.pdns_id)
-
-    return [{k: key[k] for k in ('dnskey', 'ds', 'flags', 'keytype')}
-            for key in r.json() if key['active']]
+    try:
+        r = _pdns_get('/zones/%s/cryptokeys' % domain.pdns_id)
+        keys = [{k: key[k] for k in ('dnskey', 'ds', 'flags', 'keytype')}
+                for key in r.json() if key['active']]
+    except:
+        keys = []
+
+    return keys
 
 
 def get_zone(domain):