What is the problem?
If the JSON entry does not contain a tunnels.type, the import-data.js reports the exception:
/srv/service/node_modules/mariadb/lib/misc/errors.js:61 return new SqlError(msg, sql, fatal, info, sqlState, errno, additionalStack, addHeader); ^ SqlError: Parameter at position 2 is undefined INSERT INTO tunnels (operator, type, anonymous) VALUES (?, ?, ?) - parameters:['r',undefined,true] sql: INSERT INTO tunnels (operator, type, anonymous) VALUES (?, ?, ?) - parameters:['r',undefined,true] at Object.module.exports.createError (/srv/service/node_modules/mariadb/lib/misc/errors.js:61:10) at Query.throwNewError (/srv/service/node_modules/mariadb/lib/cmd/command.js:63:16) at Query.validateParameters (/srv/service/node_modules/mariadb/lib/cmd/query.js:179:14) at Query.start (/srv/service/node_modules/mariadb/lib/cmd/query.js:53:17) at _addCommandEnablePipeline (/srv/service/node_modules/mariadb/lib/connection.js:1245:11) at /srv/service/node_modules/mariadb/lib/connection.js:177:7 at new Promise (<anonymous>) at Connection._queryPromise (/srv/service/node_modules/mariadb/lib/connection.js:174:12) at /srv/service/import-data.js:159:47 at processTicksAndRejections (node:internal/process/task_queues:96:5) { text: 'Parameter at position 2 is undefined\n' + 'INSERT INTO\n' + ' tunnels (operator, type, anonymous)\n' + ' VALUES\n' + " (?, ?, ?) - parameters:['r',undefined,true]", sql: 'INSERT INTO\n' + ' tunnels (operator, type, anonymous)\n' + ' VALUES\n' + " (?, ?, ?) - parameters:['r',undefined,true]", fatal: false, errno: 45017, sqlState: 'HY000', code: 'ER_PARAMETER_UNDEFINED' }
Steps to reproduce problem
- Save the JSON from "Reproduction data" below as a .gz file (e.g. reprod.json.gz) into the ipoid/tmp directory
- If necessary, start up docker in the ipoid directory (e.g. docker compose up -d)
- Initialise the database: docker compose exec web node init-db.js
- Run this command: docker compose exec -e FEED_PATH=./tmp/reprod.json.gz web node import-data.js
Environment
ipoid commit 9bac83bb26f9b808edc3756284a8183a4e21c5c2
Reproduction data
{"as": {}, "client": {"behaviors": [], "concentration": {}, "count": false, "countries": null, "proxies": [], "spread": null, "types": ["DESKTOP"]}, "infrastructure": false, "location": {}, "organization": false, "risks": ["TUNNEL"], "services": [], "tunnels": [{"operator": "r", "anonymous": true}], "ip": "633f9bba-6d4f-40d5-ba34-f15ac42743d3"}