Commit 87d4da9
committed
feat(rest): harden lookup/reference resolution (id fast-path + ambiguity)
Reference cells (name/email/id) now resolve more safely:
- id fast-path: try an exact id match first, so a pasted record id is
authoritative and never shadowed by a name/label collision.
- ambiguity guard: when the first matching candidate field hits >1 record,
stop and report a new 'reference_ambiguous' error instead of silently
linking whichever row came back first ($top:2 detects the dup).
- structured resolver contract: RefResolver may return { id, ambiguous,
matchedField }; bare string|undefined from legacy resolvers still works
(normalizeRefMatch).
Tests: unit (structured result + ambiguous + not-found) and integration
(duplicate-name ambiguity, id fast-path).1 parent 73fad27 commit 87d4da9
4 files changed
Lines changed: 94 additions & 18 deletions
File tree
- packages/rest/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
143 | 161 | | |
144 | 162 | | |
145 | 163 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
41 | 55 | | |
42 | 56 | | |
43 | | - | |
44 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
45 | 61 | | |
46 | 62 | | |
47 | 63 | | |
48 | 64 | | |
49 | 65 | | |
50 | 66 | | |
51 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
52 | 75 | | |
53 | 76 | | |
54 | 77 | | |
| |||
285 | 308 | | |
286 | 309 | | |
287 | 310 | | |
288 | | - | |
289 | | - | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
290 | 316 | | |
291 | 317 | | |
292 | | - | |
| 318 | + | |
293 | 319 | | |
294 | 320 | | |
295 | 321 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
182 | 208 | | |
183 | 209 | | |
184 | 210 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
3398 | 3398 | | |
3399 | 3399 | | |
3400 | 3400 | | |
3401 | | - | |
| 3401 | + | |
3402 | 3402 | | |
3403 | 3403 | | |
3404 | | - | |
3405 | | - | |
3406 | | - | |
3407 | | - | |
| 3404 | + | |
| 3405 | + | |
| 3406 | + | |
| 3407 | + | |
| 3408 | + | |
| 3409 | + | |
| 3410 | + | |
3408 | 3411 | | |
| 3412 | + | |
3409 | 3413 | | |
3410 | | - | |
| 3414 | + | |
3411 | 3415 | | |
3412 | | - | |
| 3416 | + | |
3413 | 3417 | | |
3414 | 3418 | | |
3415 | 3419 | | |
3416 | 3420 | | |
3417 | 3421 | | |
3418 | 3422 | | |
3419 | 3423 | | |
3420 | | - | |
3421 | | - | |
| 3424 | + | |
| 3425 | + | |
| 3426 | + | |
| 3427 | + | |
3422 | 3428 | | |
3423 | | - | |
3424 | | - | |
| 3429 | + | |
| 3430 | + | |
3425 | 3431 | | |
3426 | 3432 | | |
3427 | 3433 | | |
| |||
0 commit comments