[MS-1520] Don't send empty moduleIds in DeviceConfigurationUpdatedEvent - #1762
[MS-1520] Don't send empty moduleIds in DeviceConfigurationUpdatedEvent#1762BurningAXE wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes an event-sync validation issue where DeviceConfigurationUpdatedEvent could serialize downSyncModules as an empty array (rather than omitting the field), causing the backend to detect an untokenized tokenizable path.
Changes:
- Normalize
downSyncModulestonullduringsetTokenizedListFields(...)when the tokenized list is empty, preventing empty-array serialization. - Add unit tests to ensure both
nulland empty-list module selections result indownSyncModules == nullafter tokenization. - Add an event-to-API mapping test to ensure
downSyncModulesis omitted from the serializedApiEventwhen no modules are selected.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| infra/events/src/main/java/com/simprints/infra/events/event/domain/models/DeviceConfigurationUpdatedEvent.kt | Normalizes empty tokenized module list back to null to avoid emitting an empty array that triggers backend tokenization validation. |
| infra/events/src/test/java/com/simprints/infra/events/event/domain/models/DeviceConfigurationUpdatedEventTest.kt | Adds coverage for setTokenizedListFields to ensure empty module lists remain/are converted to null. |
| infra/event-sync/src/test/java/com/simprints/infra/eventsync/event/usecases/MapDomainEventToApiUseCaseTest.kt | Verifies API JSON omits downSyncModules (and produces no tokenizedFields) when modules are not selected. |
c936de6 to
42e6c2a
Compare
| payload = payload.copy( | ||
| configuration = payload.configuration.copy( | ||
| downSyncModules = map[TokenKeyType.ModuleId] ?: payload.configuration.downSyncModules, | ||
| downSyncModules = (map[TokenKeyType.ModuleId] ?: payload.configuration.downSyncModules)?.ifEmpty { null }, |
There was a problem hiding this comment.
Wouldn't it be safer to fix it in TokenizeEventPayloadFieldsUseCase:23 by filtering/skipping any fields with empty lists?
That way we would not need to remember to apply the same fix for any list field in any future events.
There was a problem hiding this comment.
Good idea! I'll rework.
42e6c2a to
50f10f4
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
infra/events/src/test/java/com/simprints/infra/events/event/domain/models/DeviceConfigurationUpdatedEventTest.kt:73
- Test name says
setTokenizableFields_*but the test actually callssetTokenizedListFields(...), which makes the intent misleading when reading failures. Rename the test to match the API under test.
fun setTokenizableFields_keepsModuleIdsNullWhenMapHasNoModuleIds() {
infra/events/src/test/java/com/simprints/infra/events/event/domain/models/DeviceConfigurationUpdatedEventTest.kt:61
- Test name says
setTokenizableFields_*but the test actually callssetTokenizedListFields(...), which makes the intent misleading when reading failures. Rename the test to match the API under test.
This issue also appears on line 73 of the same file.
fun setTokenizableFields_keepsExistingModuleIdsWhenMapHasNoModuleIds() {
|



JIRA ticket
Will be released in: 2026.3.0
Root cause analysis (for bugfixes only)
First known affected version: 2026.2.0
Notable changes
Testing guidance
Additional work checklist