-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Context
Now that we have POST /datasets and POST /subjects, the request payloads for the two endpoints differ in only one field: dataset_uuids (used by /subjects but not by /datasets).
At present, extra fields in the JSON request body are silently ignored, meaning you can feasibly send a request like:
{
"min_age": 50,
"max_age": 70,
"dataset_uuids": ["http://neurobagel.org/vocab/ds001", "http://neurobagel.org/vocab/ds002"]
}to the /datasets endpoint and get results, giving the impression that the provided dataset_uuids filter actually had an effect.
Since this behaviour can be misleading (and also makes the request body harder to test), one option is to disallow fields that aren't explicitly defined the request body model.
One downside with disallowing extra parameters is that removing or renaming existing params becomes a more "visibly" breaking change. e.g., right now, if we were to rename a query field and someone continued using the old name, it would appear as if the query still worked since results would still be returned (even though the filter itself would no longer have an effect).
Implementation
Can use:
model_config = ConfigDict(extra="forbid")Concrete problem right now
- hard to differentiate the request bodies between datasets endpoint and subjects endpoint
- makes it hard to test for "invalid" requests that should result
- makes it hard to notice bugs when we send incorrect requests to the API
- a user may send a subjects request body to datasets endpoint assuming from the silence that datasets endpoint can filter
- also typos or misspellings of fields would not be detected
Decision
- We will disallow additional parameters
Consequences:
- Old nodes will break for queries that involve new, deprecated, or misspelled request parameters
- These nodes will continue to function normally for requests that do not include the unsupported request parameters
TODO:
- Forbid extra query parameters
- (f-API / query tool): ensure that the federated response model can handle responses from different nodes that may have different shapes (i.e., if some nodes have a new parameter and others are outdated)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status