Skip to content

Filter by ID: a list of ids is not enough to make a query (steps 13 and 14) - #3

Merged
jason-fox merged 2 commits into
FIWARE:NGSI-LDfrom
kzangeli:fix/id-only-query-too-wide
Sep 21, 2026
Merged

jason-fox merged 2 commits into
FIWARE:NGSI-LDfrom
kzangeli:fix/id-only-query-too-wide

Conversation

@kzangeli

Copy link
Copy Markdown

The problem

Two requests query /entities with id as their only selector:

  • 1️⃣3️⃣ Filter Data Entities by ID — id=...&pick=id,type,temperature&format=concise
  • 1️⃣4️⃣ Returning data as GeoJSON — id=...&format=concise

Clause 10.4.3.4 of the NGSI-LD API says a query shall carry at least one of

  • a. a type selector
  • b. a list of attribute names
  • c. an NGSI-LD Query
  • d. an NGSI-LD GeoQuery
  • e. local scope

and raises BadRequestData — too wide query — if none is present. The clause says it in prose too: "it is not possible to retrieve a set of entities by only specifying desired Entity identifiers, without further specifying restrictions on the entities' types or attributes".

pick is not on that list, and is not a selector: it chooses which members of an entity are returned, not which entities are.

The fix

Adds local=true to both, which is clause (e). Two reasons to prefer it over attrs or type:

  • it keeps step 13's own point intact — "every id must be unique, so type is not required for this request";
  • attrs cannot be combined with pick; they are alternative projection mechanisms and a broker rejects the pair.

A short paragraph explains the rule so the next person editing these requests knows why the parameter is there.

Verified against a running broker: both amended requests return exactly the responses the page documents, including the GeoJSON FeatureCollection for step 14.

The same defect in tutorials.CRUD-Operations step 13 is fixed in a separate PR. Independent of #2 — different lines, no conflict.

🤖 Generated with Claude Code

Both "Filter Data Entities by ID" (13) and "Returning data as GeoJSON" (14)
query /entities with `id` as the only selector. Clause 10.4.3.4 of the NGSI-LD
API requires at least ONE of:

  a. a type selector
  b. a list of attribute names
  c. an NGSI-LD Query
  d. an NGSI-LD GeoQuery
  e. local scope

and raises BadRequestData ("too wide query") if none is present. The clause
says it in prose as well: "it is not possible to retrieve a set of entities by
only specifying desired Entity identifiers, without further specifying
restrictions on the entities' types or attributes".

`pick` is not a selector - it chooses which members of an entity are returned,
not which entities are - so neither request currently satisfies the rule.

`local=true` is used here rather than `attrs`, for two reasons: it keeps the
page's own point that `type` is not required when filtering by id, and `attrs`
cannot be combined with `pick` (they are alternative projection mechanisms).
Both amended requests were run against a broker and return exactly the
responses the page documents.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Clarified the explanation about NGSI-LD query requirements and removed redundant information.
@jason-fox
jason-fox merged commit 8a55fef into FIWARE:NGSI-LD Sep 21, 2026
1 check passed
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.

2 participants