fix(iot): 409 различает конфликт name vs device_id (ревью)

store.Create классифицирует 23505 по имени constraint: (namespace,device_id) →
ErrDeviceIDExists, иначе ErrAlreadyExists. Handler отдаёт разные 409-сообщения.
Помогает Terraform понять, какое поле конфликтует.
This commit is contained in:
Repinoid
2026-10-10 19:21:47 +03:00
parent 3b7c8a0a63
commit 3a73207abd
3 changed files with 18 additions and 0 deletions
+4
View File
@@ -15,6 +15,10 @@ var ErrNotFound = errors.New("device not found")
// ErrAlreadyExists — конфликт уникальности (namespace, name) или (namespace, device_id).
var ErrAlreadyExists = errors.New("device already exists")
// ErrDeviceIDExists — конфликт именно по (namespace, device_id) (отличается от
// конфликта по name для понятной ошибки API/Terraform, ревью 2026-10-10).
var ErrDeviceIDExists = errors.New("device_id already exists")
// Device — устройство IoT из таблицы iot_devices.
type Device struct {
Namespace string