From 22540223c43342473d7d428dffeeab9d94afb55c Mon Sep 17 00:00:00 2001 From: Pjotr Date: Thu, 8 Oct 2026 11:24:58 +0000 Subject: * src/response.rs: wrap every success response in one envelope. Breaking: every success body is now {"data", "meta": {"state", "took_ms", "request_id"}, "notes", "next"}; clients read `data`. Only `/` (plain text) and `/openapi.json` are unwrapped. * src/response.rs (Envelope, Meta, State, Ctx, RequestInfo): handlers take Ctx first and build the response with ctx.envelope(data), so timing and the request id are never filled in by hand. `state` is `complete` or `partial`; notes are server-authored only; `next` are concrete relative hrefs (path_segment percent-encodes names). * src/routes/*.rs, src/lib.rs (version): every handler returns Envelope<..> with next links; /search is `partial` when the locus lookup fails or a sorted 1000-hit window may be truncated, and /publications/{pubmed_id}/traits when datasets were left out for authorization. * src/error.rs (ApiError): add `took_ms`, an RFC 7807 extension member. * src/auth.rs (AuthToken): the 401 now carries request_id and took_ms (it never had a request_id); Ctx stores RequestInfo in the request extensions for it. * tests: common::data / envelope_data parse every success body through the envelope; tests/envelope.rs and test/python/test_envelope.py check the shape, errors, and that every `next` link resolves; tests/envelope_partial.rs checks the `partial` search without a database; tests/openapi.rs fails if a JSON success response is not an Envelope_* schema. * README.md, docs/SKILL.md, docs/gn-auth.md, RELEASE_NOTES.md: document the envelope and took_ms on errors. Co-Authored-By: Claude Sonnet 5.5 --- test/python/test_groups.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test/python/test_groups.py') diff --git a/test/python/test_groups.py b/test/python/test_groups.py index 0c55a8f..a3dcb55 100644 --- a/test/python/test_groups.py +++ b/test/python/test_groups.py @@ -9,7 +9,7 @@ import json import unittest from auth_helpers import TOKEN_ENV, auth_token -from server_test_case import database_reachable, HOST, PORT, ServerTestCase +from server_test_case import database_reachable, HOST, PORT, ServerTestCase, envelope_data @@ -32,7 +32,7 @@ class GroupsTest(ServerTestCase): conn.close() self.assertEqual(response.status, 200) - groups = json.loads(body) + groups = envelope_data(body) self.assertTrue(groups) names = {record["name"] for record in groups} self.assertIn("BXD", names) @@ -53,7 +53,7 @@ class GroupsTest(ServerTestCase): response = conn.getresponse() body = response.read() self.assertEqual(response.status, 200, path) - return json.loads(body) + return envelope_data(body) finally: conn.close() -- cgit 1.4.1