fix: don't request id as a property (omit it) for id/geometry-only OGC calls#906
Draft
thodson-usgs wants to merge 1 commit into
Draft
fix: don't request id as a property (omit it) for id/geometry-only OGC calls#906thodson-usgs wants to merge 1 commit into
id as a property (omit it) for id/geometry-only OGC calls#906thodson-usgs wants to merge 1 commit into
Conversation
…try-only calls `switch_properties_id()` strips the feature id and `geometry` from the wire `properties` (the feature id is always returned and renamed downstream; geometry is controlled by `skipGeometry`). When a user requested only the id and/or geometry, the list became empty and the function fell back to `properties <- "id"`. That fallback now fails: several collections (e.g. `daily`, `continuous`) reject `id` as a selectable property, and it also fails the available-properties check in `construct_api_requests()`, so e.g. `read_waterdata_daily(properties = "daily_id")` errors with `Invalid properties: id`. Fall back to `NA_character_` instead, which omits the `properties` filter entirely. The feature id still comes back and `rejigger_cols()` subsets the result to the requested column, so id/geometry-only requests succeed on every collection (verified live against daily, continuous, and monitoring-locations). Collections that still accept `id` (e.g. monitoring-locations) are unchanged. Adds a unit test for `switch_properties_id()` covering the id/geometry-only and mixed cases. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
|
@ldecicco-USGS , |
Collaborator
|
There's a conversation about it going on with the API developers. They pushed out an update last night and I think it wasn't intentional that "id" now isn't allowed in the properties query - but it does sound like the official pygeoapi platform doesn't include "id" in the property list. So this is probably a permanent change, but not 100% confirmed. dataRetrieval had already dropped "id" from the property list query because it seemed redundant - you always get an id back whether you ask for it or not. So, it wouldn't be a terrible idea to do this fix (both packages would act the same). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
read_waterdata_*(properties = "<id column>")(or only id + geometry) errors:switch_properties_id()correctly strips the feature id andgeometryfrom the wireproperties(the featureidis always returned and renamed downstream; geometry is controlled byskipGeometry). But when the request was only the id and/or geometry, the list became empty and it fell back toproperties <- "id". That fallback no longer works: the USGS OGC API now rejectsidas a selectable property on several collections (e.g.daily,continuous), andidalso fails the available-properties check inconstruct_api_requests().This is the same upstream API change that affected the Python
dataretrievalpackage; the R package's normal multi-property path already dropsidcorrectly, so only the id/geometry-only fallback is affected.Fix
Fall back to
NA_character_instead of"id", which omits thepropertiesfilter entirely. The featureidstill comes back regardless, andrejigger_cols()subsets the result to the requested column — so id/geometry-only requests now succeed on every collection.Verified live:
daily/continuous(rejectid): previously errored, now return a valid result (the syntheticdaily_id/continuous_idis dropped for these services by design, as before).monitoring-locations(acceptsid, keeps the id column): returns the id column, unchanged from current behavior.The only cost is that an id/geometry-only request now fetches all columns and subsets client-side (the API can no longer return just
id); this is a rare request and avoids the error.Tests
Adds a
switch_properties_id()unit test (no network) covering the id/geometry-only and mixed cases — it asserts the fallback omitsproperties(NA) rather than producing"id".🤖 Generated with Claude Code