fix(repositories): handle None values in resource_search filters (#101)#102
Merged
fix(repositories): handle None values in resource_search filters (#101)#102
Conversation
resource_search crashed with AttributeError when resources had None values in name, url, description or format fields. dict.get(key, '') only returns the default when the key is missing, not when it exists with value None, so .lower() was being called on None. Use (resource.get(key) or '') in all filter branches and add a regression test covering None values across all searchable fields. Closes #101
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AttributeError: 'NoneType' object has no attribute 'lower'in/resources/searchwhen a resource hasNonevalues inname,url,descriptionorformat(resource_search crashes with AttributeError when resource fields are None #101)resource.get(key, \"\")with(resource.get(key) or \"\")in every filter branch ofDataCatalogRepository.resource_search— the previous form only falls back to the default when the key is missing, not when it exists with valueNoneNonevalues across all searchable fields (query, name, url, format, description)0.10.11and updateCHANGELOG.mdTest plan
docker compose exec api python -m pytest tests/ -v— 1012 passedtest_search_with_none_fields_does_not_crashpasses and fails on the previous codeAttributeError, after the fix returns a valid result setblack --checkandflake8 --max-line-length=88clean on the modified filesCloses #101