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
Timeset validation accepts vectors mixing YYYYMMDD and YYYYWW, and pvt_twitter()/pub_wiki() send weekly values on the day parameter without checking `time_type #400
While working through day-vs-week confusion (open issues #286/#278 describe the user-facing symptom: confusingly empty results), I traced it to two concrete validation gaps:
parse_timeset_input() accepts any integer/character vector where every element is 6-or-8 characters — so a vector mixing day values (20200101) and week values (202201) passes validation unchanged and is sent comma-joined on one wire parameter.
pvt_twitter() and pub_wiki() select dates vs epiweeks purely from time_type but never verify the values' format against it — so pvt_twitter(auth, "CA", time_values = epirange(201501, 202001)) with the default time_type = "day" sends a weekly range (201501-202001) as a day value.
I think client-side validation (uniform granularity per vector; nchar cross-check against time_type) would turn these silent misfires into clear errors, complementing the error-message improvements discussed in #286/#278.
Mixed vectors are sent comma-joined on one wire parameter with unspecified server semantics.
Expected vs. actual
Expected: client-side rejection (or loud warning) when timeset values don't match the endpoint's expected granularity.
Actual: validation passes; the mismatch is only discoverable from an opaque server-side outcome.
Suggested fix
In parse_timeset_input(), require uniform granularity per vector: reject when any(nchar(value) == 6) && any(nchar(value) == 8).
In pvt_twitter()/pub_wiki(), cross-check before the call: for time_type == "day" require nchar 8 (or 10-char dates), for "week" require 6; abort client-side with a message pointing at time_type.
I checked for prior reports: open #286 ("Weekly data should require week numbers") and #278 ("Raise error when dates / date range are passed to things expecting weeks?") describe the user-facing confusion in pub_covidcast/pub_flusurv terms; this report adds the concrete validation gaps (mixed vectors; pvt_twitter/pub_wiki lacking any cross-check). Happy to consolidate into either if preferred.
Summary
While working through day-vs-week confusion (open issues #286/#278 describe the user-facing symptom: confusingly empty results), I traced it to two concrete validation gaps:
parse_timeset_input()accepts any integer/character vector where every element is 6-or-8 characters — so a vector mixing day values (20200101) and week values (202201) passes validation unchanged and is sent comma-joined on one wire parameter.pvt_twitter()andpub_wiki()selectdatesvsepiweekspurely fromtime_typebut never verify the values' format against it — sopvt_twitter(auth, "CA", time_values = epirange(201501, 202001))with the defaulttime_type = "day"sends a weekly range (201501-202001) as a day value.I think client-side validation (uniform granularity per vector;
ncharcross-check againsttime_type) would turn these silent misfires into clear errors, complementing the error-message improvements discussed in #286/#278.Evidence (dev tip 87b10e1; same code on
main)R/check.R:91-96:c(20200101, 202201)→ every element is 8-or-6 → returned unchanged, mixed.time_typecross-check —pvt_twitter(R/endpoints.R:3205-3245) andpub_wiki(R/endpoints.R:3290-3330):validate_timeset_input()is then applied todates/epiweekswith no relation to the chosentime_type.Maintainer-runnable repro
Impact
time_type = "week"— the server presumably errors or returns nothing, and underreturn_empty = TRUEthe user gets a silent empty tibble (the Weekly data should require week numbers #286/Raise error when dates / date range are passed to things expecting weeks? #278 symptom, with the concrete validation gap that would catch it earliest).Expected vs. actual
Suggested fix
parse_timeset_input(), require uniform granularity per vector: reject whenany(nchar(value) == 6) && any(nchar(value) == 8).pvt_twitter()/pub_wiki(), cross-check before the call: fortime_type == "day"requirenchar8 (or 10-char dates), for"week"require 6; abort client-side with a message pointing attime_type.I checked for prior reports: open #286 ("Weekly data should require week numbers") and #278 ("Raise error when dates / date range are passed to things expecting weeks?") describe the user-facing confusion in
pub_covidcast/pub_flusurvterms; this report adds the concrete validation gaps (mixed vectors;pvt_twitter/pub_wikilacking any cross-check). Happy to consolidate into either if preferred.