Commit f7d631a
fix(forms): validate required bridge message fields (MAGE-484) (#437)
* fix(forms): throw on missing required fields in bridge message parsing
Add a requireString() extension on JSONObject that throws
IllegalArgumentException when a required field is missing or empty.
The existing catch-and-log in KlaviyoNativeBridge.postMessage() prevents
malformed events from propagating to the host app.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
* test: verify warning log when CTA has no Android route
The empty-android-route test verified that neither the lifecycle handler
nor DeepLinking were invoked, but didn't verify the warning log fires.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
* fix: make FormDisappeared tolerant of missing fields to prevent stuck overlays
FormDisappeared now uses optString instead of requireString so that
dismiss() always fires even if the JS bridge sends malformed data.
Also fixes test assertions to verify log level rather than exact message
content, per project guidelines.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
* refactor(forms): move lifecycle validation from bridge parsing to event dispatch
Parsing now always uses optString() with empty defaults so SDK-internal
actions (present overlay, dismiss, handle deep links) are never blocked
by missing metadata. Validation of formId/formName/buttonLabel is done
in KlaviyoNativeBridge's show/close/deepLink methods right before
dispatching FormLifecycleEvent to the host app callback.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
* fix: address PR review nits — remove redundant optString defaults, use level-only log assertions
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
* fix(forms): allow empty buttonLabel on CTA events
A CTA button with no text label is still a valid click event.
Only formId and formName are required non-empty for the lifecycle callback.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
* docs(forms): fix lifecycle event timing documentation
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
* fix(forms): improve test validity and assertions
Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
* docs(forms): remove internal implementation details from public API docs
Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>1 parent acf8b8f commit f7d631a
6 files changed
Lines changed: 207 additions & 74 deletions
File tree
- sdk
- forms-core/src/main/java/com/klaviyo/forms
- forms/src
- main/java/com/klaviyo/forms/bridge
- test/java/com/klaviyo/forms
- bridge
Lines changed: 13 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
33 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
34 | 41 | | |
35 | 42 | | |
36 | 43 | | |
37 | 44 | | |
38 | 45 | | |
39 | 46 | | |
40 | 47 | | |
41 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
42 | 53 | | |
43 | 54 | | |
44 | 55 | | |
| |||
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
99 | 107 | | |
100 | 108 | | |
101 | 109 | | |
| |||
129 | 137 | | |
130 | 138 | | |
131 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
132 | 148 | | |
133 | 149 | | |
134 | 150 | | |
| |||
144 | 160 | | |
145 | 161 | | |
146 | 162 | | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
147 | 171 | | |
148 | 172 | | |
149 | 173 | | |
| |||
Lines changed: 9 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | | - | |
| 157 | + | |
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
165 | | - | |
166 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
167 | 168 | | |
168 | 169 | | |
169 | 170 | | |
| 171 | + | |
170 | 172 | | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
171 | 176 | | |
172 | 177 | | |
173 | 178 | | |
| |||
178 | 183 | | |
179 | 184 | | |
180 | 185 | | |
181 | | - | |
| 186 | + | |
182 | 187 | | |
183 | 188 | | |
184 | 189 | | |
| |||
Lines changed: 84 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
| 117 | + | |
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
121 | 124 | | |
122 | 125 | | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
123 | 130 | | |
124 | 131 | | |
125 | 132 | | |
126 | 133 | | |
127 | 134 | | |
128 | 135 | | |
129 | 136 | | |
130 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
131 | 149 | | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
132 | 154 | | |
133 | 155 | | |
134 | 156 | | |
| |||
264 | 286 | | |
265 | 287 | | |
266 | 288 | | |
267 | | - | |
| 289 | + | |
| 290 | + | |
268 | 291 | | |
269 | 292 | | |
270 | 293 | | |
| |||
290 | 313 | | |
291 | 314 | | |
292 | 315 | | |
293 | | - | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
294 | 320 | | |
295 | 321 | | |
296 | 322 | | |
| |||
305 | 331 | | |
306 | 332 | | |
307 | 333 | | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
308 | 359 | | |
309 | 360 | | |
310 | 361 | | |
| |||
335 | 386 | | |
336 | 387 | | |
337 | 388 | | |
338 | | - | |
| 389 | + | |
339 | 390 | | |
340 | 391 | | |
341 | 392 | | |
| |||
356 | 407 | | |
357 | 408 | | |
358 | 409 | | |
359 | | - | |
| 410 | + | |
360 | 411 | | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
361 | 416 | | |
362 | 417 | | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
363 | 421 | | |
364 | 422 | | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
365 | 440 | | |
366 | 441 | | |
367 | 442 | | |
| |||
378 | 453 | | |
379 | 454 | | |
380 | 455 | | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
| 456 | + | |
388 | 457 | | |
389 | 458 | | |
390 | 459 | | |
391 | 460 | | |
392 | 461 | | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
| 462 | + | |
400 | 463 | | |
401 | 464 | | |
402 | 465 | | |
403 | 466 | | |
404 | 467 | | |
405 | 468 | | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
| 469 | + | |
412 | 470 | | |
413 | 471 | | |
0 commit comments