A Meter PATCH Ignores Zero and Empty-String Values
Level 2 · node · API · Partial update confuses falsy values with omitted fields
Scenario
A fictional facility meter configuration API partially updates each meter's alert threshold and display label. Operators may explicitly set the threshold to zero for immediate alerts or clear the display label using an empty string. The current service uses truthiness to decide which fields to update and silently ignores both requests. Review the flow from repository to controller.
Requirements
When a property is explicitly present in the request, save its value even if it is zero or an empty string. Preserve old values for omitted fields, existing nonzero updates, and errors for unknown meters. Updates must not affect other meters. Do not add external packages.
Acceptance criteria
- A threshold explicitly set to zero is saved.
- An explicitly empty display label is saved.
- Fields omitted from the request keep their previous values.
- A nonzero threshold update continues to work.
- Updating an unknown meter returns an error.
- Changing one meter does not alter another meter.