Fleet has two code paths that turn the same host_emails rows into a device_mapping array, and today they
disagree in the ordering used:
Path A — sorted (ORDER BY email, source) via listHostDeviceMappingDB → ListHostDeviceMapping. This
serves:
- GET /hosts/{id}/device_mapping — the host details page (hosts.go:2240)
- PUT /hosts/{id}/device_mapping — returns the updated list after adding a custom email (hosts.go:2357)
- GET /device/{token}/device_mapping — the end-user "My Device" page (devices.go:420)
Path B — unordered (GROUP_CONCAT with no ORDER BY) via the list query. This serves:
- GET /hosts?device_mapping=true — the Hosts table (hosts.go:1311)
- GET /labels/{id}/hosts?device_mapping=true — a label's host list (labels.go:1237)
- GET /hosts/report — the CSV export (same query)
We need to decide whether this is something worth fixing or if its inconsequential
Fleet has two code paths that turn the same host_emails rows into a device_mapping array, and today they
disagree in the ordering used:
Path A — sorted (ORDER BY email, source) via listHostDeviceMappingDB → ListHostDeviceMapping. This
serves:
Path B — unordered (GROUP_CONCAT with no ORDER BY) via the list query. This serves:
We need to decide whether this is something worth fixing or if its inconsequential