Concatenated Site and Sensor IDs Overwrite Unrelated Readings
Level 2 · node · Data · Composite identifier key collision overwrites sensor records
Scenario
A fictional distributed equipment service stores the latest reading for each combination of site ID and sensor ID. Both identifiers are variable-length strings. Site ab with sensor c and site a with sensor bc refer to different devices, yet the current implementation maps both to the same storage key and overwrites a reading. Inspect how the repository, service, and controller represent composite identifiers.
Requirements
Construct storage keys that cannot collide between distinct site and sensor pairs. Reads and updates must be isolated by pair. Unknown pairs return null, and invalid readings must not modify existing records. Do not add dependencies or network access.
Acceptance criteria
- Distinct site and sensor identifier pairs retain independent readings.
- The first pair remains retrievable after the second pair is recorded.
- The second pair returns its own recorded reading.
- Updating one pair does not modify the other pair.
- An unknown pair returns null.
- Invalid readings are rejected without modifying stored values.