Skip to content

/data: a FIPS code without scale analyzes the area as given (EJAM#764) - #66

Open
ejanalysis wants to merge 1 commit into
mainfrom
fix-764-data-fips-scale
Open

ejanalysis wants to merge 1 commit into
mainfrom
fix-764-data-fips-scale

Conversation

@ejanalysis

@ejanalysis ejanalysis commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Fixes Public-Environmental-Data-Partners/EJAM#764. Part of the EJAM v4.2024.1 milestone.

Problem: POST /data with a FIPS code and no scale failed with HTTP 400 and {"error":["argument is of length zero"]}. The cause: scale = NULL reached if (fips_type == scale) in fipper().

Change:

  • A missing or blank scale now returns one row per FIPS area as given, the same as /report. Before this, the call failed, so no working request changes.
  • scale is trimmed and lower-cased. Anything other than "blockgroup" or "county" returns a clear 400 message.
  • The scale parameter text in the API docs says what each value returns.
  • A new test, tests/test-data-fips-scale.R, uses the same stub approach as test-zip-api.R and is added to the existing CI workflow. It fails on main and passes here.

Checked locally by running this rest_controller.r with EJAM 4.2024.0:

Request body Result
{"fips":"10001"} 200, 1 row (New Castle County, pop 187,604)
{"fips":"10001","scale":"county"} 200
{"fips":"10","scale":"county"} 200, 3 rows (the three Delaware counties)
{"fips":"10001","scale":"tract"} 400, scale must be "blockgroup" or "county", or left out…

Notes:

  • After this merges into main, also merge main into version4-2024-0. The v4 test API is built from that branch, not from main. Without that step this fix doesn't reach the v4 test API. (The same applies to Warm up reports at start-up, and add GET /warmup #65, so one merge of main after both is enough.)
  • This doesn't overlap the warm-up PR Warm up reports at start-up, and add GET /warmup #65: that one edits near line 701, and this one edits fipper() and the /data parameter docs.
  • After this merges, EJAM's verbatim copy in inst/plumber/ejam-api/ needs a re-sync (see its SYNC.md). Otherwise EJAM's drift-check test will flag the difference.
  • Open question for reviewers: should no scale mean "as given" (this PR) or "one row per block group" (fipper()'s own default)? "As given" matches /report, and it avoids returning thousands of rows for a state.

— Claude (AI assistant), posting from ejanalysis account

🤖 Generated with Claude Code

POST /data with fips and no scale failed with HTTP 400 "argument is of
length zero", because scale = NULL reached `if (fips_type == scale)` in
fipper(). A missing or blank scale now returns one row per FIPS area as
given, as /report does. An unknown scale is a clear 400 message.
Documents what each scale value returns, and adds a stubbed route test
to the existing CI workflow.

Fixes Public-Environmental-Data-Partners/EJAM#764

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ejanalysis

Copy link
Copy Markdown
Contributor Author

Codex review of head 96b2d502: no actionable defects found.

Nothing was merged or deployed.

— Claude (AI assistant), posting from ejanalysis account, relaying a review by Codex (AI assistant)

🤖 Generated with Claude Code

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.

API /data with a FIPS code fails ("argument is of length zero") unless scale is given

1 participant