about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPjotr Prins <pjotr.public01@thebird.nl>2026-11-17 17:39:46 +0000
committerPjotr Prins <pjotr.public01@thebird.nl>2026-11-17 17:39:46 +0000
commit9aff34fad9df147c999e1bccb0e380f202dffed8 (patch)
tree5537f1de81040f1a4c4256de33b7c66248ac4479
parentf2ec41256c3cb6b2952cb06f5f45d97b9814fc82 (diff)
downloadgenenetwork4-9aff34fad9df147c999e1bccb0e380f202dffed8.tar.gz
docs: the listing shape -- what it does, what is wired, and the one open question
Five of six listings take limit_to/ids_only/names_only with the old shape as the
default; docs/listings.md is the client-facing description plus the mechanics
(why the reply type is an untagged Rows enum, why the utoipa body= must move
with it, and why that mismatch reports itself as a missing __path_ handler).

It also records the one that is not done, with the measurement that matters:
/traits/{dataset} answers the full list whatever parameters are sent, which is
what a handler that never receives its Query does -- so the next step is the
operationId of that path in /openapi.json, not another edit to traits.rs.
-rw-r--r--docs/listings.md78
-rw-r--r--docs/migration.md2
2 files changed, 79 insertions, 1 deletions
diff --git a/docs/listings.md b/docs/listings.md
new file mode 100644
index 0000000..86b2fb0
--- /dev/null
+++ b/docs/listings.md
@@ -0,0 +1,78 @@
+# The listing shape: `limit_to`, `ids_only`, `names_only`
+
+Three optional query parameters, the ones GeneNetwork2 offers and this API did
+not, on the listings a client has to enumerate:
+
+```
+GET /groups?names_only=true
+GET /groups/BXD/traits?ids_only=true&limit_to=10001,BXD_0001
+GET /datasets/HC_M2_0606_P/probesets?names_only=true
+```
+
+## The rule that makes it safe
+
+**No listing parameters means exactly the answer this API has always given.**
+The reply body is an untagged `Rows` enum (`Objects` or `Plain`), so the wire
+shape is a plain JSON array either way and the default path is unchanged; only
+the slim forms answer one value per row. That was the point of the design: the
+default tenant of this API is an existing client, and a wrapper object would
+have been a breaking change dressed up as a feature.
+
+* `limit_to=a,b,c` keeps the rows whose id, name, trait name, display name or
+  full name matches one of the values, case-insensitively. Rows keep their
+  order.
+* `ids_only=true` answers one id per row; `names_only=true` one name.
+* Asking for both shapes at once is a **422 `invalid_listing`** rather than a
+  parse-order coin toss.
+* A `limit_to` value that matches nothing is **named in the reply's note**. A
+  silent empty answer is how "my trait is missing" becomes undiagnosable.
+
+## Where it is wired (2026-11-16)
+
+| endpoint | state |
+|---|---|
+| `GET /groups` | yes |
+| `GET /groups/{group}/strains` | yes |
+| `GET /groups/{group}/datasets` | yes |
+| `GET /groups/{group}/traits` | yes — 15 060 traits in BXDPublish, the case that motivated this |
+| `GET /datasets/{dataset}/probesets` | yes — 45 101 probesets |
+| `GET /traits/{dataset}` | **no** — see below |
+
+Payloads for scale: `/datasets/HC_M2_0606_P/probesets` is 45 101 objects,
+`/groups/BXD/traits` 15 060, `/groups/BXD/strains` 396.
+
+## Why `/traits/{dataset}` is not wired
+
+This listing returns probe *and* phenotype traits in one array, each row tagged
+`category: "probeset"` (verified against a live reply — the rows are flattened,
+so `category` is a field and a probeset's identifier is `probeset_id`; there is
+no `id`). A bare id is therefore ambiguous, and the intended slim form is
+`category:value` (`"probeset:1427571_at"`, `"publish:10001"`).
+
+Wire it was attempted and withdrawn: with the fields read correctly the
+parameters were still ignored — every request answered the full 45 101 objects,
+which is what a handler that never sees its `Query` does. Before editing that
+handler again, settle one question: **which function serves `/traits/{dataset}`**.
+`src/lib.rs` registers `traits`, `trait_info` and `trait_values` on overlapping
+prefixes, so check the `operationId` of that path in `/openapi.json` rather than
+assuming it is `traits.rs`'s `traits`.
+
+## Mechanics, for whoever adds the next one
+
+Three edits per handler plus one that is easy to miss:
+
+1. the three fields on the handler's query struct — or, if it has none, take
+   `crate::listing::ListingParams` directly (it is `IntoParams`, so it documents
+   itself);
+2. the return type: `Envelope<Vec<T>>` → `Envelope<crate::listing::Rows>`;
+3. shape the rows where the envelope is built, appending the `limit_to` note;
+4. **and** the `body =` type in the handler's `utoipa::path` block.
+   `utoipa` typechecks that annotation against the return type, so changing one
+   and not the other fails as `could not find __path_<handler>` pointing at
+   `lib.rs`'s `routes!` macro — a misleading error that sends you to the wrong
+   file. This is the whole reason a `Rows` enum beats an `Envelope<Value>`: the
+   annotation changes by one word and the compiler keeps checking the real type.
+
+Also: `axum::extract::Query` must be in scope (three of the six handlers never
+used it), and a handler whose `Found` branch builds its envelope inline
+(`Ok(Json(ctx.envelope(...)))`) has to open that branch into a block.
diff --git a/docs/migration.md b/docs/migration.md
index b3f0d64..bd9879d 100644
--- a/docs/migration.md
+++ b/docs/migration.md
@@ -30,7 +30,7 @@ already exists in the API.
     | feature                              | GN1  | GN2 | GN3  | effort | why                                                       |
     +--------------------------------------+------+-----+------+--------+-----------------------------------------------------------+
     | correlation matrix                   | yes  | yes | no   | S-M    | decisions recorded; N^2 calls to the live correlate_named |
-    | limit_to / ids_only / names_only     | no   | yes | no   | S      | optional query params on existing listings                |
+    | limit_to / ids_only / names_only     | no   | yes | no   | S      | 5 of 6 listings done 2026-11-16 (docs/listings.md); /traits/{dataset} open -- its rows are flattened and its Query never arrives, so check which handler serves it first |
     | tissue correlation                   | yes  | yes | yes  | S-M    | TissueProbeSetData is in the DB; the maths already exists |
     | literature correlation               | yes  | yes | yes  | S-M    | LCorrRamin3 is a lookup table, no statistics involved     |
     | whole-dataset sample matrix export   | yes  | yes | yes  | S-M    | one SQL sweep; the only choice is streaming/CSV vs JSON   |