Commit 761ed9d
authored
feat: Add FDv2 payload handling to the data source event handler (#305)
## What this adds
`DataSourceEventHandler.handlePayload`: the entry point the FDv2 data
pipeline (a later PR) calls when a payload completes. Nothing produces
payloads for the event handler yet, so behavior is unchanged.
The method maps the payload's updates to item descriptors with the
flag-eval mapper, applies them through `FlagManager.applyChanges` (full
replaces, partial applies, none takes no action), and marks the data
source valid — a payload of any type, including none, confirms the
connection is delivering current data. Unparseable flag data is
classified as an `invalidData` error and reported through the status
manager, mirroring how the FDv1 message verbs handle bad payloads; the
in-progress payload is discarded.
## Testing
New tests cover all three transfer types end to end through the event
handler (full replaces the stored flags and applies the environment ID,
partial applies updates without per-item version comparison, none
changes no data), the valid status transition, and invalid flag data
producing an `invalidData` error with `MessageStatus.invalidMessage`.
SDK-2186
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Isolated new API path with no callers yet; behavior mirrors existing
FDv1 error handling and delegates storage semantics to existing
`applyChanges`.
>
> **Overview**
> Adds **`DataSourceEventHandler.handlePayload`**, the FDv2 entry point
that maps payload updates through `mapUpdatesToItemDescriptors`, applies
them via **`FlagManager.applyChanges`** (full replace, partial merge
without per-flag version checks, **none** leaves flags unchanged),
optionally sets **environment ID** on full transfers, and always marks
the data source **valid** on success.
>
> Invalid flag-eval data follows the same pattern as FDv1 verbs: log,
**`ErrorKind.invalidData`**, return **`MessageStatus.invalidMessage`**,
and discard the payload. Nothing in this PR wires FDv2 streaming into
the handler yet.
>
> Tests exercise full/partial/none behavior, valid status, environment
ID on full payloads, and malformed flag-eval objects.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
c44bdeb. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent c677c3d commit 761ed9d
2 files changed
Lines changed: 121 additions & 0 deletions
File tree
- packages/common_client
- lib/src/data_sources
- test/data_sources
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
96 | 98 | | |
97 | 99 | | |
98 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
99 | 123 | | |
100 | 124 | | |
101 | 125 | | |
| |||
Lines changed: 97 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
284 | 285 | | |
285 | 286 | | |
286 | 287 | | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 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 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
287 | 384 | | |
288 | 385 | | |
0 commit comments