All problems

Reordered Inspection Answers Saved to Wrong Items

Level 2 · node · Data · Answers mapped by array position instead of item ID

Scenario

A fictional equipment inspection service merges responses from field devices into a server-side checklist template. Each response includes a unique item ID, but synchronization can change the order of the response array. The current merge logic ignores IDs and assigns responses by position, attaching valid inspection results to the wrong checklist items.

Requirements

Match each response to the template item with the same itemId. Reordering responses must not change the result. Ignore unknown item IDs, leave unanswered items as null, and preserve template order.

Acceptance criteria

  • Responses in template order map to the correct items.
  • Reordering responses preserves each item's value by ID.
  • An unknown item ID does not overwrite a known item.
  • An unanswered item remains null.