Fix cantaloupe sync column mapping — greedy name keyword matches Location Name #5

Closed
opened 2026-05-21 23:20:51 +00:00 by shawn · 0 comments
Owner

Problem

The Cantaloupe sync API column mapping had a greedy matching bug. The heuristic keyword "name" (single word) was matching "Location Name" headers before the more specific "location name" keyword could match. This caused asset names to be stored in the _location_name field and vice versa.

Fix

  1. Changed matching from substring (kw in norm or norm in kw) to word-subset matching (kw_words subset of norm_words)
  2. Normalize keywords the same way as headers (replace _ and # with spaces)
  3. Reorder heuristics: multi-word specific patterns before single-word generic ones
  4. Added 10 unit tests covering normalization, mapping, diff computation, Excel parsing
  5. Added 23 integration tests covering all 5 API endpoints end-to-end

Commits

  • f7ffa0e — fix column mapping heuristic, add comprehensive tests

Test Results

  • 10/10 unit tests pass
  • 23/23 integration tests pass
## Problem The Cantaloupe sync API column mapping had a greedy matching bug. The heuristic keyword "name" (single word) was matching "Location Name" headers before the more specific "location name" keyword could match. This caused asset names to be stored in the `_location_name` field and vice versa. ## Fix 1. Changed matching from substring (kw in norm or norm in kw) to word-subset matching (kw_words subset of norm_words) 2. Normalize keywords the same way as headers (replace _ and # with spaces) 3. Reorder heuristics: multi-word specific patterns before single-word generic ones 4. Added 10 unit tests covering normalization, mapping, diff computation, Excel parsing 5. Added 23 integration tests covering all 5 API endpoints end-to-end ## Commits - f7ffa0e — fix column mapping heuristic, add comprehensive tests ## Test Results - 10/10 unit tests pass - 23/23 integration tests pass
shawn closed this issue 2026-05-21 23:20:51 +00:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shawn/canteen-admin-server#5