Skip to content

Comma-joined signals/geo_type with a space after the comma fails with "not an available signal" — the split doesn't trim whitespace #407

Description

@docxology

Summary

While using the documented comma-joined style for v5 signals, I hit a confusing failure: epidata_snapshot("nhsn", "pct_visits, urgent_care", "state") errors with "not an available signal" because the comma-split at R/endpoints.R:1576-1577 (and :1688-1689 in epidata_archive()) uses strsplit(..., fixed = TRUE) without trimws(), so the second signal arrives as " urgent_care" with a leading space. The comma-joined input style is the documented one (R/endpoints.R:1461-1462), so this is a small but real papercut; a trimws() before unique() fixes it.

Evidence (dev tip 87b10e1)

# R/endpoints.R:1576-1577 (epidata_snapshot; same at :1688-1689 in epidata_archive)
signals <- unique(unlist(strsplit(signals, ",", fixed = TRUE)))
geo_type <- unique(unlist(strsplit(geo_type, ",", fixed = TRUE)))
strsplit("pct_visits, urgent_care", ",", fixed = TRUE)
# [[1]] "pct_visits" " urgent_care"   <- leading space preserved

Note: the in-flight PR #380 (send signals comma-joined in one request per geo_type) reworks this fan-out but keeps the same untrimmed split, so the papercut survives it.

Maintainer-runnable repro

epidata_snapshot("nhsn", "pct_visits, urgent_care", "state")
# error: " urgent_care" is not an available signal for source nhsn...

Suggested fix

signals <- unique(trimws(unlist(strsplit(signals, ",", fixed = TRUE))))
geo_type <- unique(trimws(unlist(strsplit(geo_type, ",", fixed = TRUE))))

(applied in both epidata_snapshot() and epidata_archive()).

I checked for prior reports (open/closed issues about signal names or the comma style — #380's PR is the in-flight rework) and found none covering the trimming.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions