All problems

Uppercase Vibration Units Are Stored Without Normalization

Level 2 · node · API · Missing canonical unit normalization after input validation

Scenario

A fictional industrial motor vibration API accepts mm/s and in/s case-insensitively. Stored records and responses must use lowercase canonical units. The service currently lowercases the unit for validation but saves the original spelling, making identical units appear under multiple names. Inspect the repository, service, and controller flow.

Requirements

Validate units and store the canonical lowercase representation. Reject unsupported units and non-finite numeric readings without modifying history. Preserve per-device isolation, insertion order, and empty history for unknown devices. Add no dependencies.

Acceptance criteria

  • Valid vibration readings are stored with their supported units.
  • Unsupported units are rejected without modifying stored history.
  • Supported units containing uppercase letters are stored in canonical lowercase form.
  • Non-finite numeric inputs are rejected without changing history.
  • Histories are isolated by device and preserve insertion order.
  • Unknown devices return an empty history.