-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
What went wrong?
I have some tests that query the IOOS Data Catalog ('https://data.ioos.us/api/action/package_search) and it seems to be giving a 502 error:
https://github.com/ioos/ioos_metrics/actions/runs/15210347163/job/42782794744?pr=131
Operating System
Windows
Version
?
Python Version
?
Code to Reproduce
ioos_catalog.action.package_search()Errors, Traceback, and Logs
url = 'https://data.ioos.us/api/action/package_search', status = 502
response = '<html>\r\n<head><title>502 Bad Gateway</title></head>\r\n<body>\r\n<center><h1>502 Bad Gateway</h1></center>\r\n<hr><center>nginx/1.22.1</center>\r\n</body>\r\n</html>\r\n'
def reverse_apicontroller_action(url, status, response):
"""
Make an API call look like a direct action call by reversing the
exception -> HTTP response translation that ApiController.action does
"""
try:
parsed = json.loads(response)
if parsed.get('success'):
return parsed['result']
if hasattr(parsed, 'get'):
err = parsed.get('error', {})
else:
err = {}
except (AttributeError, ValueError):
err = {}
if not isinstance(err, dict): # possibly a Socrata API.
raise ServerIncompatibleError(repr([url, status, response]))
etype = err.get('__type')
emessage = err.get('message', '')
if hasattr(emessage, 'split'):
emessage = emessage.split(': ', 1)[-1]
if etype == 'Search Query Error':
# I refuse to eval(emessage), even if it would be more correct
raise SearchQueryError(emessage)
elif etype == 'Search Error':
# I refuse to eval(emessage), even if it would be more correct
raise SearchError(emessage)
elif etype == 'Search Index Error':
raise SearchIndexError(emessage)
elif etype == 'Validation Error':
raise ValidationError(err)
elif etype == 'Not Found Error':
raise NotFound(emessage)
elif etype == 'Authorization Error':
raise NotAuthorized(err)
# don't recognize the error
> raise CKANAPIError(repr([url, status, response]))
E ckanapi.errors.CKANAPIError: ['https://data.ioos.us/api/action/package_search', 502, '<html>\r\n<head><title>502 Bad Gateway</title></head>\r\n<body>\r\n<center><h1>502 Bad Gateway</h1></center>\r\n<hr><center>nginx/1.22.1</center>\r\n</body>\r\n</html>\r\n']
.pixi/envs/default/lib/python3.13/site-packages/ckanapi/common.py:134: CKANAPIErrorMetadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Backlog