Internal server error upload a device that has an invalid parent
gcampax opened this issue · 0 comments
gcampax commented
From the logs:
Error: ER_NO_REFERENCED_ROW_2: Cannot add or update a child row: a foreign key constraint fails (`thingengine_staging`.`device_class_kind`, CONSTRAINT `device_class_kind_ibfk_2` FOREIGN KEY (`kind`) REFERENCES `device_schema` (`kind`) ON DELETE CASCADE ON UPDATE CASCADE)
at Query.Sequence._packetToError (/opt/almond-cloud/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
at Query.ErrorPacket (/opt/almond-cloud/node_modules/mysql/lib/protocol/sequences/Query.js:79:18)
at Protocol._parsePacket (/opt/almond-cloud/node_modules/mysql/lib/protocol/Protocol.js:291:23)
at Parser._parsePacket (/opt/almond-cloud/node_modules/mysql/lib/protocol/Parser.js:433:10)
at Parser.write (/opt/almond-cloud/node_modules/mysql/lib/protocol/Parser.js:43:10)
at Protocol.write (/opt/almond-cloud/node_modules/mysql/lib/protocol/Protocol.js:38:16)
at TLSSocket.ondata (_stream_readable.js:718:22)
at TLSSocket.emit (events.js:314:20)
at TLSSocket.EventEmitter.emit (domain.js:483:12)
at addChunk (_stream_readable.js:297:12)
--------------------
at Protocol._enqueue (/opt/almond-cloud/node_modules/mysql/lib/protocol/Protocol.js:144:48)
at PoolConnection.query (/opt/almond-cloud/node_modules/mysql/lib/Connection.js:198:25)
at /opt/almond-cloud/util/db.js:76:16
at new Promise (<anonymous>)
at doQuery (/opt/almond-cloud/util/db.js:75:12)
at Object.query (/opt/almond-cloud/util/db.js:105:16)
at insertKinds (/opt/almond-cloud/model/device.js:33:15)
at Object.create (/opt/almond-cloud/model/device.js:50:9)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async /opt/almond-cloud/util/import_device.js:547:17 {
code: 'ER_NO_REFERENCED_ROW_2',
errno: 1452,
sqlMessage: 'Cannot add or update a child row: a foreign key constraint fails (`thingengine_staging`.`device_class_kind`, CONSTRAINT `device_class_kind_ibfk_2` FOREIGN KEY (`kind`) REFERENCES `device_schema` (`kind`) ON DELETE CASCADE ON UPDATE CASCADE)',
sqlState: '23000',
index: 0,
sql: "insert into device_class_kind(device_id, kind, is_child) values (542, 'org.thingpedia.iot.speaker', false)"
}