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

[DO NOT MERGE YET] Error handling and logging for global and policy searches #6581

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

johnnyporkchops
Copy link
Contributor

@johnnyporkchops johnnyporkchops commented Dec 4, 2024

Summary

Related ticket: #6557

  • Handle errors for the global site search and Policy Guidance search when the FEC API or search.gov API do not return search-result data
  • Use a catch-all Try/Except block handle Connection Errors when the FEC API endpoints (Candidtes or Committees) or search.gov API are not responding. Also handle Key Error, JSON Decode Error or any other error that arises when the data retunred is not processable, search-result json.
  • Render an error message to the search-result page and log errors in server logs.

Required reviewers

One developer, One UX

Impacted areas of the application

General components of the application that this PR will affect:

  • Global site search

  • Policy Guidance search

    modified: fec/static/scss/components/_messages.scss
    modified: search/templates/search/policy_guidance_search_page.html
    modified: search/templates/search/search.html
    modified: search/views.py

Screenshot

If a search term returns no results, but there is also an error:

(If there is no error, it would show only the default no-result message, no need to list the types that were successfully searched)
Contingent on #6557

Screenshot 2024-12-04 at 11 39 31 PM

How to test

  • Export the SEARCHGOV_API_ACCESS_KEY and SEARCHGOV_POLICY_GUIDANCE_KEY in terminal or add to bash_profile or zsh profile and source the profile in terminal.
  • npm run build-sass
  • Using the global site search box or Policy Guidance search box:
    • Test a JSON Decode Error by breaking the search.gov URL by changing a character in the URL in serach/views.py line 113.
    • Test a Key Error by exporting the wrong access key for search.gov, like export SEARCHGOV_API_ACCESS_KEY=1234
    • Test a Connection Error by changing the url on line 113 of serach/views.py to a site that does nor exist like: https://www.doesnotexist.com
  • See the error messages on the results page
  • See the errors logged in your terminal
  • No results message: You can search this string (which has consistently returned no results) to see how errors are handled when there are no-results : "tkts" (screenshot above)

Copy link

codecov bot commented Dec 5, 2024

Codecov Report

Attention: Patch coverage is 65.85366% with 14 lines in your changes missing coverage. Please review.

Project coverage is 79.82%. Comparing base (acd68c6) to head (364f7b7).
Report is 6 commits behind head on develop.

Files with missing lines Patch % Lines
fec/search/views.py 65.85% 14 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #6581      +/-   ##
===========================================
- Coverage    79.91%   79.82%   -0.09%     
===========================================
  Files          235      235              
  Lines         5147     5175      +28     
===========================================
+ Hits          4113     4131      +18     
- Misses        1034     1044      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@patphongs patphongs changed the title Error handling and logging for global and policy searches [DO NOT MERGE YET] Error handling and logging for global and policy searches Dec 10, 2024
@rfultz rfultz modified the milestones: 26.i, 27.1 Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Error handling for search.gov
2 participants