You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a repo maintainer/data consumer of zippeR::zi_get_geometry(), I want a clear, actionable error when county isn't supplied as a valid 5-digit GEOID, so that a malformed request (e.g. passing a county name string) fails loudly instead of silently returning a zero-row result.
Tier: tier/quick-win — low-effort (single input-validation check, matching the existing state/method validation style already in zi_get_geometry()), moderate-impact (prevents a confusing silent-failure UX gap)
Describe the bug
zi_get_geometry()'s county parameter is documented as requiring "a character scalar or vector with character GEOIDs (e.x. "29510")" (see R/zi_get_geometry.R roxygen @param county). If a user instead passes a human-readable county name (e.g. "St. Louis City"), the function does not validate the format and silently proceeds:
zi_get_geometry(year=2020, state="MO", county="St. Louis City", method="centroid")
Internally, zi_process_county() does counties <- counties[counties$GEOID %in% county, ], which matches zero rows when county isn't a real GEOID, and the function ultimately returns a zero-row sf object with no warning or error — easy to mistake for a package bug (as happened during UAT of #133/PR #138) rather than a usage error.
Expected behavior
zi_get_geometry() should validate that county values are 5-digit numeric-like GEOID strings (mirroring the existing state/method/year argument-checking style already in the function) and cli::cli_abort() with a clear message when they aren't, e.g.:
county must be a 5-digit character GEOID (e.g. "29510"). You provided "St. Louis City".
To Reproduce
zi_get_geometry(year=2020, state="MO", county="St. Louis City", method="centroid")
#> Simple feature collection with 0 features and 1 field -- no error, silent zero rows# correct usage (should be the only accepted form):
zi_get_geometry(year=2020, state="MO", county="29510", method="centroid")
#> Simple feature collection with 19 features and 1 field -- works as expected
Desktop (please complete the following information):
R/zi_get_geometry.R: zi_get_geometry() (~line 122) already validates year, style, class, return, shift_geo, and method with explicit cli::cli_abort() checks near the top of the function — county has no equivalent check and should follow the same pattern.
R/zi_get_geometry.R: zi_process_county() (~line 435) is where the silent zero-row result actually originates (counties[counties$GEOID %in% county, ]).
Parent epic: #109
User story
As a repo maintainer/data consumer of
zippeR::zi_get_geometry(), I want a clear, actionable error whencountyisn't supplied as a valid 5-digit GEOID, so that a malformed request (e.g. passing a county name string) fails loudly instead of silently returning a zero-row result.Tier:
tier/quick-win— low-effort (single input-validation check, matching the existingstate/methodvalidation style already inzi_get_geometry()), moderate-impact (prevents a confusing silent-failure UX gap)Describe the bug
zi_get_geometry()'scountyparameter is documented as requiring "a character scalar or vector with character GEOIDs (e.x."29510")" (seeR/zi_get_geometry.Rroxygen@param county). If a user instead passes a human-readable county name (e.g."St. Louis City"), the function does not validate the format and silently proceeds:Internally,
zi_process_county()doescounties <- counties[counties$GEOID %in% county, ], which matches zero rows whencountyisn't a real GEOID, and the function ultimately returns a zero-rowsfobject with no warning or error — easy to mistake for a package bug (as happened during UAT of #133/PR #138) rather than a usage error.Expected behavior
zi_get_geometry()should validate thatcountyvalues are 5-digit numeric-like GEOID strings (mirroring the existingstate/method/yearargument-checking style already in the function) andcli::cli_abort()with a clear message when they aren't, e.g.:To Reproduce
Desktop (please complete the following information):
Additional context
"29510", bothmethod = "centroid"andmethod = "intersect"return the expected non-zero row count. The zero-row result was a UAT usage error, not a regression from refactor: convert dplyr rename/rename_with/bind_rows and remaining pipeline-glue call sites to Base R #133 — filing this purely as an ergonomics/validation gap.Codebase Context
R/zi_get_geometry.R:zi_get_geometry()(~line 122) already validatesyear,style,class,return,shift_geo, andmethodwith explicitcli::cli_abort()checks near the top of the function —countyhas no equivalent check and should follow the same pattern.R/zi_get_geometry.R:zi_process_county()(~line 435) is where the silent zero-row result actually originates (counties[counties$GEOID %in% county, ]).