Skip to content

Commit

Permalink
Update FetchDiscoveryDoc to return first valid discovery doc (#283)
Browse files Browse the repository at this point in the history
_NormalizeDiscoveryUrls returns two api formats. We should take the first valid discovery doc url rather than always using the second.
  • Loading branch information
jameslynnwu committed Oct 18, 2019
1 parent 6d64cb6 commit fa4e407
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions apitools/gen/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,8 @@ def FetchDiscoveryDoc(discovery_url, retries=5):
if isinstance(content, bytes):
content = content.decode('utf8')
discovery_doc = json.loads(content)
break
if discovery_doc:
return discovery_doc
except (urllib_error.HTTPError, urllib_error.URLError) as e:
logging.info(
'Attempting to fetch discovery doc again after "%s"', e)
Expand All @@ -412,4 +413,3 @@ def FetchDiscoveryDoc(discovery_url, retries=5):
raise CommunicationError(
'Could not find discovery doc at any of %s: %s' % (
discovery_urls, last_exception))
return discovery_doc

0 comments on commit fa4e407

Please sign in to comment.