|
13 | 13 | * |:--|:--|:--| |
14 | 14 | * | `GET ?$select=`, `?$select=%20`, `?$select=,`, `?select=`, `?fields=` | 200, every column | 400 naming the spelling | |
15 | 15 | * | `GET ?$count=maybe`, `?$count=1`, `?count=` (with `$top`) | 200, `total` reported | 400 naming the spelling | |
16 | | - * | `POST {"select":""}`, `{"fields":[]}` | 200, every column | 400 naming the key | |
| 16 | + * | `POST {"select":""}`, `{"fields":[]}` | 200, every column | 400 naming the key (`select` at the body schema, `VALIDATION_FAILED`, since #26909) | |
17 | 17 | * | `POST {"count":"maybe"}` | 400 `VALIDATION_FAILED` (the body schema) | unchanged | |
18 | 18 | * | `GET /:id?select=`, `?select=,` | 200, every column | `VALIDATION_ERROR` naming `select`, at this route's 404 (it rewrote every 400, as for `?select=nope`); 400 since #26816 | |
19 | 19 | * | `GET ?$select=label`, `?$count=true` / `false`, absent; `GET /:id?select=label` | 200 | unchanged | |
@@ -59,11 +59,22 @@ const REFUSED_GET: ReadonlyArray<readonly [string, Record<string, string>, strin |
59 | 59 |
|
60 | 60 | /** name · the JSON body `POST /data/:object/query` receives · the key the refusal names. */ |
61 | 61 | const REFUSED_POST: ReadonlyArray<readonly [string, Record<string, unknown>, string]> = [ |
62 | | - ['select: ""', { select: '' }, 'select'], |
63 | | - ['$select: ","', { $select: ',' }, '$select'], |
64 | 62 | ['fields: []', { fields: [] }, 'fields'], |
65 | 63 | ]; |
66 | 64 |
|
| 65 | +/** |
| 66 | + * [#26909] The body's published schema (`FindDataRequestSchema`) now declares |
| 67 | + * the projection the normalizer enforces, so these are refused where every |
| 68 | + * other malformed body is: at the schema, `400 VALIDATION_FAILED`, `fields[0]` |
| 69 | + * naming `query.<key>` (the #25269 precedent for the page window). |
| 70 | + */ |
| 71 | +const REFUSED_POST_AT_SCHEMA: ReadonlyArray<readonly [string, Record<string, unknown>, string]> = [ |
| 72 | + ['select: ""', { select: '' }, 'query.select'], |
| 73 | + ['$select: ","', { $select: ',' }, 'query.$select'], |
| 74 | + ['select: []', { select: [] }, 'query.select'], |
| 75 | + ['select: ["label", ""]', { select: ['label', ''] }, 'query.select'], |
| 76 | +]; |
| 77 | + |
67 | 78 | function createMockServer() { |
68 | 79 | const noop = () => {}; |
69 | 80 | return { get: noop, post: noop, put: noop, delete: noop, patch: noop, use: noop, listen: async () => {}, close: async () => {} }; |
@@ -161,6 +172,17 @@ describe('[#26644] an empty projection and an unrecognised count flag on the Dat |
161 | 172 | expect(reads.n - before, 'no read of the object — every refusal precedes the driver').toBe(0); |
162 | 173 | }); |
163 | 174 |
|
| 175 | + it('POST query: `select` / `$select` naming no field is the schema door\'s 400 VALIDATION_FAILED — no read', async () => { |
| 176 | + const before = reads.n; |
| 177 | + for (const [name, body, field] of REFUSED_POST_AT_SCHEMA) { |
| 178 | + const res = await query(body); |
| 179 | + expect(res.status, `${name}: ${JSON.stringify(res.body)}`).toBe(400); |
| 180 | + expect(res.body.code, name).toBe('VALIDATION_FAILED'); |
| 181 | + expect(res.body.fields?.[0]?.field, name).toBe(field); |
| 182 | + } |
| 183 | + expect(reads.n - before, 'no read of the object — every refusal precedes the driver').toBe(0); |
| 184 | + }); |
| 185 | + |
164 | 186 | it("POST query: an unrecognised count is still the schema door's 400 VALIDATION_FAILED, unchanged", async () => { |
165 | 187 | const res = await query({ limit: 2, count: 'maybe' }); |
166 | 188 | expect(res.status, JSON.stringify(res.body)).toBe(400); |
|
0 commit comments