Commit 734de98
committed
feat(console): settings validation errors render against the fields that caused them (objectstack#4224 follow-up)
A `SETTINGS_VALIDATION` rejection names the offending keys, and this page threw
all of it away — every failure collapsed into one toast carrying the server's
summary sentence, with nothing marked on the inputs. On a namespace with a dozen
keys the user was told a value was wrong and left to find which.
That was not the console's fault. The server sent `fields` as a
`Record<key, message>` hung BESIDE `error.code`, a position `ApiErrorSchema`
never declared; it survived only because the schema is a plain `z.object` that
strips undeclared keys instead of rejecting them. `extractFieldErrors` reads
arrays (`details.fields` / `fields` / `validationErrors`), so a map at an
undeclared position matched nothing and returned null. objectstack#4224 moved it
to `error.details.fields` as the declared `FieldError[]` — which is what makes
this wiring a few lines rather than a parser.
- `SettingsField` gains an `error` prop, rendered in the slot the help text
occupies rather than stacked under it: the two say the same kind of thing, and
a description sitting below a red error reads as two states at once.
- The mark is on the CONTROL, not just beside it — `aria-invalid` plus
`aria-describedby` pointing at a `role="alert"` message. Colour is not a cue
for everyone. Wiring it in `wrapper` covers every input type at once.
- Cleared per-field the moment that field is edited (the error describes the
value the server saw, so it contradicts what is in the box), and wholesale on
Discard, on reload, and on a successful save.
- Fields the server did not name stay unmarked, and a failure carrying no field
array (500, unknown namespace) behaves exactly as before.
The toast still fires alongside the marks: the offending field can be scrolled
out of view or hidden behind a `visible` expression, and a save that appears to
do nothing is the worse failure.
Five tests drive the real post-#4224 wire body rather than a hand-tuned fixture,
so a server regression to the map turns them red instead of passing against a
shape nobody sends. Verified to fail without the wiring.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tv2NYMBTrzVVRWiWWuyec51 parent c4d7b20 commit 734de98
4 files changed
Lines changed: 362 additions & 6 deletions
File tree
- .changeset
- apps/console/src/pages/settings
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
49 | 59 | | |
50 | 60 | | |
51 | 61 | | |
| |||
132 | 142 | | |
133 | 143 | | |
134 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
135 | 162 | | |
136 | | - | |
| 163 | + | |
137 | 164 | | |
138 | 165 | | |
139 | 166 | | |
| |||
231 | 258 | | |
232 | 259 | | |
233 | 260 | | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
234 | 267 | | |
235 | 268 | | |
236 | 269 | | |
237 | | - | |
238 | | - | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
239 | 281 | | |
240 | 282 | | |
241 | 283 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
45 | 52 | | |
46 | 53 | | |
47 | 54 | | |
| |||
53 | 60 | | |
54 | 61 | | |
55 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
56 | 73 | | |
57 | 74 | | |
58 | 75 | | |
| |||
61 | 78 | | |
62 | 79 | | |
63 | 80 | | |
| 81 | + | |
64 | 82 | | |
65 | 83 | | |
66 | 84 | | |
| |||
127 | 145 | | |
128 | 146 | | |
129 | 147 | | |
| 148 | + | |
130 | 149 | | |
131 | 150 | | |
132 | 151 | | |
| |||
135 | 154 | | |
136 | 155 | | |
137 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
138 | 170 | | |
139 | 171 | | |
140 | 172 | | |
| |||
194 | 226 | | |
195 | 227 | | |
196 | 228 | | |
197 | | - | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
198 | 238 | | |
199 | 239 | | |
200 | 240 | | |
201 | 241 | | |
| 242 | + | |
202 | 243 | | |
203 | 244 | | |
204 | 245 | | |
| |||
211 | 252 | | |
212 | 253 | | |
213 | 254 | | |
214 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
215 | 266 | | |
216 | 267 | | |
217 | 268 | | |
| |||
0 commit comments