DEV-15826: Handle no matching toptier on agency office autocomplete endpoints - #4728
Open
gregrholden wants to merge 6 commits into
Open
DEV-15826: Handle no matching toptier on agency office autocomplete endpoints#4728gregrholden wants to merge 6 commits into
gregrholden wants to merge 6 commits into
Conversation
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.
Description:
DEV-15826: Handle no matching toptier on agency office autocomplete endpoints [f9019].
The
references/autocomplete.py'sBaseAutocompleteViewSetclass contains a logic error wheretoptier_agencyis referenced incorrectly in thesubtier_agencylookup loop.Technical Details:
At first glance, it looked like the error was due to cases where an empty
toptier_agencyvariable had not been instantiated, but is then later called in thesubtier_agencyloop, throwing an error. Upon further inspection, it appears the reference totoptier_agencyis incorrect altogether. Alltoptier_agencyresults are handled in thetoptier_agencyloop on lines 107-134. Referencing this variable in a latersubtier_agencyloop would only reference the last iteration value from the toptier loop, potentially returning stale and/or incorrect data for the subtier iteration. Since it might not have been instantiated, it also opened the door to the reported errors happening when no toptier agency gets used.The fix is straightforward: Update the
subtier_agencyloop so it correctly searches thesubtier_agencyoffice values instead of thetoptier_agencyoffice values, which have already been handleld in an earlier loop. Tests have been added to cover cases where subtier agencies are all that are present in the autocomplete lookup for both awarding and funding agencies.Requirements for PR Merge:
Explain N/A in above checklist: