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

add validation to filters in legal/search endpoint #6088

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

Conversation

pkfec
Copy link
Contributor

@pkfec pkfec commented Dec 19, 2024

Summary (required)

Required reviewers

2 developers

Impacted areas of the application

  • legal/search endpoints

How to test

on local:

On Dev: Deploy a feature/test branch and test the filters against Dev api

-test filters:

Copy link

codecov bot commented Dec 19, 2024

Codecov Report

Attention: Patch coverage is 95.65217% with 1 line in your changes missing coverage. Please review.

Project coverage is 88.47%. Comparing base (02b2fbd) to head (97cd455).

Files with missing lines Patch % Lines
webservices/filters.py 92.85% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #6088      +/-   ##
===========================================
+ Coverage    88.46%   88.47%   +0.01%     
===========================================
  Files           82       82              
  Lines         9091     9110      +19     
===========================================
+ Hits          8042     8060      +18     
- Misses        1049     1050       +1     

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

@pkfec pkfec changed the title add validation to ao_requestor_type filter add validation to few dropdown filters Dec 19, 2024
@pkfec pkfec linked an issue Dec 19, 2024 that may be closed by this pull request
1 task
@pkfec pkfec self-assigned this Dec 19, 2024
@pkfec pkfec changed the title add validation to few dropdown filters add validation to filters Dec 19, 2024
Copy link
Member

@cnlucas cnlucas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job dealing with a tricky issue, and thank you for cleaning up the code!

  1. My understanding was FE wants all of the filters to have the same behavior—should we confirm and open a follow-up ticket for the other filters? What about type, ao_is_pending, ao_citation_require_all, case_citation_require_all—can they be updated in this PR since they also have the option in swagger —?
  2. If someone includes an empty string and a string it throws a 500—should we update the check_filter_exists function to not throw a 500? IE http://localhost:5000/v1/legal/search/?type=advisory_opinions&ao_requestor_type=1&ao_requestor_type=

@fec-jli
Copy link
Contributor

fec-jli commented Dec 23, 2024

I agree with @cnlucas.
We should update the check_filter_exists function, something like if len(val) > 0 and '' not in val). Also the check_filter_exists function name is better like filter_validation(kwargs, filter)

@pkfec
Copy link
Contributor Author

pkfec commented Dec 27, 2024

@cnlucas

  1. type: existing validation works well and throws 422 error incase an empty string or invalid string type is passed as a parameter which is why i didn't add any additional checks.
    Few examples:

ao_is_pending, ao_citation_require_all, case_citation_require_all: All three are boolean type filters
any value other than True/False, is already giving a 422 error. I don't think additional validation is required on these 3 filters
Few examples:

@pkfec
Copy link
Contributor Author

pkfec commented Dec 27, 2024

@cnlucas

  1. ao_requestor_type filter is unique compared to other ones. I have added a custom validation check to return values even an invalid or empty string is passed on to this filter. Thanks for catching 500 error. I fixed the empty string validation error.

@pkfec pkfec force-pushed the feature/6024-legal-search-validate-dropdown-filters branch from da4fc87 to 2b3abbd Compare December 27, 2024 03:15
@pkfec pkfec requested a review from cnlucas December 27, 2024 03:31
@pkfec pkfec changed the title add validation to filters add validation to filters in legal/search endpoint Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 👀 Ready
Development

Successfully merging this pull request may close these issues.

Make empty string behavior consistent on the legal search endpoint
3 participants