Repository navigation
Fix KeyError 'GEO_ID' when CensusAPI gets both group and variables - #4
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
Passing both
groupandvariablestoCensusAPIraised the following inmelt(), for ACS and decennial endpoints alike:Root cause
_build_request()setsget=<variables>whenever variables are given, but_fetch()sent any request with a group to_fetch_group(). The API returnsGEO_ID/NAMEautomatically only for thegroup(...)query form._fetch_variables()is the path that adds them togetexplicitly. With both arguments, a plain variable list went through the group path, so the response had noGEO_ID.get=sentGEO_IDreturnedgrouponlygroup(P1)variablesonlyGEO_ID,NAME,P1_001NP1_001NFix
_fetch()uses_fetch_group()only whenvariables is None.self.groupis unchanged, so checking variables against the group and the group-based concept/universe labels still work.Changes
morpc_census/api.py: dispatch condition in_fetch()tests/test_api.py: newTestFetchDispatch(3 tests); the group+variables test fails before the fixCHANGELOG.md,reference/dev_notes.md: entriespyproject.toml: addsenlightento dependencies. This is unrelated to the fix and was already pending locally.Testing
dec/dhc2020,dec/pl2020 andacs/acs52023 all return long data withgeoidfq/name🤖 Generated with Claude Code