Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error handling for search.gov #6525

Open
4 tasks
patphongs opened this issue Oct 23, 2024 · 0 comments · May be fixed by #6581
Open
4 tasks

Error handling for search.gov #6525

patphongs opened this issue Oct 23, 2024 · 0 comments · May be fixed by #6581

Comments

@patphongs
Copy link
Member

patphongs commented Oct 23, 2024

Summary

What we're after:
When search.gov is down, we need a way to put up an error message for the user if their API returns an error code. We use search.gov for site search and policy and guidance. It would need to be updated in both places.

Slack message reporting issue:
https://fecgov.slack.com/archives/C0F6L9KFW/p1729696983236669

def search_site(query, limit=0, offset=0):
"""Calls the Search.gov website and then processes the results if successful"""
params = {
'affiliate': 'betafec_api',
'access_key': settings.SEARCHGOV_API_ACCESS_KEY,
'query': query,
'limit': limit,
'offset': offset
}
r = requests.get('https://api.gsa.gov/technology/searchgov/v2/results/i14y', params=params)
if r.status_code == 200:
return process_site_results(r.json(), limit=limit, offset=offset)

fec-cms/fec/search/views.py

Lines 146 to 158 in 92acb50

def policy_guidance_search_site(query, limit=0, offset=0):
"""Calls the Search.gov policy and guidance search and then processes the results if successful"""
params = {
'affiliate': 'fec_content_s3',
'access_key': settings.SEARCHGOV_POLICY_GUIDANCE_KEY,
'query': query,
'limit': limit,
'offset': offset
}
r = requests.get('https://api.gsa.gov/technology/searchgov/v2/results/i14y', params=params)
if r.status_code == 200:
return process_site_results(r.json(), limit=limit, offset=offset)

Related issues

List any relevant related issue(s)

Action Items

  • We should mirror what happens with USA jobs
  • Draft an error message with content for when search.gov is down
  • Meet with design to draft what we should produce in the search results

Completion criteria

  • When search.gov is down we have an error message instead of returning no results or crashing the website
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 📥 Assigned
Development

Successfully merging a pull request may close this issue.

4 participants