Skip to content

Switch ACS/SF1/PL endpoints on fields() too#168

Open
c-tonneslan wants to merge 1 commit into
datamade:masterfrom
c-tonneslan:fix/switch-endpoints-on-fields
Open

Switch ACS/SF1/PL endpoints on fields() too#168
c-tonneslan wants to merge 1 commit into
datamade:masterfrom
c-tonneslan:fix/switch-endpoints-on-fields

Conversation

@c-tonneslan
Copy link
Copy Markdown

tables() and get() on the ACS, SF1, and PL clients each wrap themselves with a _switch_endpoints call so the dataset-specific URLs are set before the request goes out. fields() doesn't, so it just inherits Client.fields() and hits whatever URL was set last (or the generic Census one), which 404s and the response fails to decode as JSON.

The reason it usually looks fine is that calling tables() first happens to set the endpoint as a side effect. Hitting fields() before anything else is the broken path (@ptwales' repro in the issue).

Added the wrapper to all three clients that already had this pattern. Also added a test_fields test mirroring test_tables.

Closes #138.

tables() and get() on the ACS, SF1, and PL clients call
_switch_endpoints first to point at the correct dataset URL.
fields() didn't, so it inherits Client.fields() unchanged and
hits whatever endpoint was set last (or the generic Census one),
which 404s and produces a JSON decode error.

Calling tables() first happens to mask this because tables flips
the endpoint as a side effect. Hitting fields() before anything
else is the broken path.

Closes datamade#138.

Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Need to _switch_endpoints on fields

1 participant