Page MenuHomePhabricator

Add fallbacks for entity properties
Closed, ResolvedPublic

Description

@STran How robust do we need/want this to be?

I find with input data:

{"as": {}, "client": {"behaviors": [], "concentration": {}, "count": true, "countries": true, "proxies": [0], "spread": false, "types": []}, "infrastructure": false, "location": {}, "organization": false, "risks": [], "services": [], "tunnels": [], "ip": "6dda8fa6-e044-498c-b66d-bcd90f3e99c6"}
{"as": {}, "client": {"behaviors": [], "concentration": {"city": "", "country": 0}, "count": false, "countries": false, "proxies": [false], "spread": false, "types": []}, "infrastructure": false, "location": {}, "organization": "", "risks": [], "services": [], "tunnels": [], "ip": "039e2d19-8584-40cf-ad18-474f0f09c05b"}

I get:

/srv/service/node_modules/mariadb/lib/misc/errors.js:61
  return new SqlError(msg, sql, fatal, info, sqlState, errno, additionalStack, addHeader);
         ^

SqlError: (conn=1045, no: 1054, SQLState: 42S22) Unknown column 'undefined' in 'field list'
sql: INSERT INTO
                actor_data_proxies (actor_data_id,proxy_id)
            VALUES
                (2, undefined) - parameters:[]
    at Object.module.exports.createError (/srv/service/node_modules/mariadb/lib/misc/errors.js:61:10)
    at PacketNodeEncoded.readError (/srv/service/node_modules/mariadb/lib/io/packet.js:511:19)
    at Query.readResponsePacket (/srv/service/node_modules/mariadb/lib/cmd/resultset.js:46:28)
    at PacketInputStream.receivePacketBasic (/srv/service/node_modules/mariadb/lib/io/packet-input-stream.js:104:9)
    at PacketInputStream.onData (/srv/service/node_modules/mariadb/lib/io/packet-input-stream.js:169:20)
    at Socket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:315:12)
    at readableAddChunk (node:internal/streams/readable:289:9)
    at Socket.Readable.push (node:internal/streams/readable:228:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
  text: "Unknown column 'undefined' in 'field list'",
  sql: 'INSERT INTO\n' +
    '                actor_data_proxies (actor_data_id,proxy_id)\n' +
    '            VALUES\n' +
    '                (2, undefined) - parameters:[]',
  fatal: false,
  errno: 1054,
  sqlState: '42S22',
  code: 'ER_BAD_FIELD_ERROR'
}

I have also seen similar errors reported with the actor_data_behaviors table.

I think something to do with the fact you have got both "proxies": [0] and "proxies": [false], which both get changed to 0 when attempting to insert into the database, so the second INSERT will fail. Notice that you can swap the order of those two lines and still get the same error.

FYI, I am using this script to generate the JSON for import: https://gitlab.wikimedia.org/dwalden/ipmasking-testing/-/blob/main/spur_random_data.py

@dom_walden do you know what data caused the error in actor_data_behaviors?

Details

Related Changes in GitLab:
TitleReferenceAuthorSource BranchDest Branch
Add fallback values for entityType and riskTyperepos/mediawiki/services/ipoid!13stranadd-property-fallbacksmain
Customize query in GitLab

Event Timeline

Restricted Application added a subscriber: Aklapper. ยท View Herald TranscriptJun 15 2023, 6:47 AM

@dom_walden do you know what data caused the error in actor_data_behaviors?

Just modifying the example from the description:

{"as": {}, "client": {"behaviors": [0], "concentration": {}, "count": true, "countries": true, "proxies": [], "spread": false, "types": []}, "infrastructure": false, "location": {}, "organization": false, "risks": [], "services": [], "tunnels": [], "ip": "6dda8fa6-e044-498c-b66d-bcd90f3e99c6"}
{"as": {}, "client": {"behaviors": [false], "concentration": {"city": "", "country": 0}, "count": false, "countries": false, "proxies": [], "spread": false, "types": []}, "infrastructure": false, "location": {}, "organization": "", "risks": [], "services": [], "tunnels": [], "ip": "039e2d19-8584-40cf-ad18-474f0f09c05b"}

FYI, I have only been able to reproduce the issue with commit 8400f97f21ff3aa3bae82fb33dfdd4d5369075f4.

The above data passed to import-data.js in the latest commit (deed45d61626f952ce8b9365e12e8bd98703fa17) returns:

{"name":"data-import","hostname":"b883017c2e42","pid":500,"level":50,"err":{"message":"Parameter at position 4 is undefined\nREPLACE INTO\n            actor_data (ip,org,client_count,types,conc_geohash,conc_city,conc_state,conc_country,conc_skew,conc_density,countries,location_country,risks)\n        VALUES\n            (?,?,?,?,?,?,?,?,?,?,?,?,?) - parameters:['6dda8fa6-e044-498c-...]\nsql: REPLACE INTO\n            actor_data (ip,org,client_count,types,conc_geohash,conc_city,conc_state,conc_country,conc_skew,conc_density,countries,location_country,risks)\n        VALUES\n            (?,?,?,?,?,?,?,?,?,?,?,?,?) - parameters:['6dda8fa6-e044-498c-...]","name":"Error","stack":"Error: Parameter at position 4 is undefined\nREPLACE INTO\n            actor_data (ip,org,client_count,types,conc_geohash,conc_city,conc_state,conc_country,conc_skew,conc_density,countries,location_country,risks)\n        VALUES\n            (?,?,?,?,?,?,?,?,?,?,?,?,?) - parameters:['6dda8fa6-e044-498c-...]\nsql: REPLACE INTO\n            actor_data (ip,org,client_count,types,conc_geohash,conc_city,conc_state,conc_country,conc_skew,conc_density,countries,location_country,risks)\n        VALUES\n            (?,?,?,?,?,?,?,?,?,?,?,?,?) - parameters:['6dda8fa6-e044-498c-...]\n    at Object.module.exports.createError (/srv/service/node_modules/mariadb/lib/misc/errors.js:61:10)\n    at Query.throwNewError (/srv/service/node_modules/mariadb/lib/cmd/command.js:63:16)\n    at Query.validateParameters (/srv/service/node_modules/mariadb/lib/cmd/query.js:179:14)\n    at Query.start (/srv/service/node_modules/mariadb/lib/cmd/query.js:53:17)\n    at _addCommandEnablePipeline (/srv/service/node_modules/mariadb/lib/connection.js:1245:11)\n    at /srv/service/node_modules/mariadb/lib/connection.js:177:7\n    at new Promise (<anonymous>)\n    at Connection._queryPromise (/srv/service/node_modules/mariadb/lib/connection.js:174:12)\n    at writeEntityToDb (/srv/service/import-data.js:76:35)\n    at Transform.transform [as _transform] (/srv/service/import-data.js:217:19)","code":"ER_PARAMETER_UNDEFINED"},"ip":"6dda8fa6-e044-498c-b66d-bcd90f3e99c6","msg":"Parameter at position 4 is undefined\nREPLACE INTO\n            actor_data (ip,org,client_count,types,conc_geohash,conc_city,conc_state,conc_country,conc_skew,conc_density,countries,location_country,risks)\n        VALUES\n            (?,?,?,?,?,?,?,?,?,?,?,?,?) - parameters:['6dda8fa6-e044-498c-...]\nsql: REPLACE INTO\n            actor_data (ip,org,client_count,types,conc_geohash,conc_city,conc_state,conc_country,conc_skew,conc_density,countries,location_country,risks)\n        VALUES\n            (?,?,?,?,?,?,?,?,?,?,?,?,?) - parameters:['6dda8fa6-e044-498c-...]","time":"2023-06-15T12:39:48.412Z","v":0}
{"name":"data-import","hostname":"b883017c2e42","pid":500,"level":50,"err":{"message":"Parameter at position 4 is undefined\nREPLACE INTO\n            actor_data (ip,org,client_count,types,conc_geohash,conc_city,conc_state,conc_country,conc_skew,conc_density,countries,location_country,risks)\n        VALUES\n            (?,?,?,?,?,?,?,?,?,?,?,?,?) - parameters:['039e2d19-8584-40cf-...]\nsql: REPLACE INTO\n            actor_data (ip,org,client_count,types,conc_geohash,conc_city,conc_state,conc_country,conc_skew,conc_density,countries,location_country,risks)\n        VALUES\n            (?,?,?,?,?,?,?,?,?,?,?,?,?) - parameters:['039e2d19-8584-40cf-...]","name":"Error","stack":"Error: Parameter at position 4 is undefined\nREPLACE INTO\n            actor_data (ip,org,client_count,types,conc_geohash,conc_city,conc_state,conc_country,conc_skew,conc_density,countries,location_country,risks)\n        VALUES\n            (?,?,?,?,?,?,?,?,?,?,?,?,?) - parameters:['039e2d19-8584-40cf-...]\nsql: REPLACE INTO\n            actor_data (ip,org,client_count,types,conc_geohash,conc_city,conc_state,conc_country,conc_skew,conc_density,countries,location_country,risks)\n        VALUES\n            (?,?,?,?,?,?,?,?,?,?,?,?,?) - parameters:['039e2d19-8584-40cf-...]\n    at Object.module.exports.createError (/srv/service/node_modules/mariadb/lib/misc/errors.js:61:10)\n    at Query.throwNewError (/srv/service/node_modules/mariadb/lib/cmd/command.js:63:16)\n    at Query.validateParameters (/srv/service/node_modules/mariadb/lib/cmd/query.js:179:14)\n    at Query.start (/srv/service/node_modules/mariadb/lib/cmd/query.js:53:17)\n    at _addCommandEnablePipeline (/srv/service/node_modules/mariadb/lib/connection.js:1245:11)\n    at /srv/service/node_modules/mariadb/lib/connection.js:177:7\n    at new Promise (<anonymous>)\n    at Connection._queryPromise (/srv/service/node_modules/mariadb/lib/connection.js:174:12)\n    at writeEntityToDb (/srv/service/import-data.js:76:35)\n    at Transform.transform [as _transform] (/srv/service/import-data.js:217:19)","code":"ER_PARAMETER_UNDEFINED"},"ip":"039e2d19-8584-40cf-ad18-474f0f09c05b","msg":"Parameter at position 4 is undefined\nREPLACE INTO\n            actor_data (ip,org,client_count,types,conc_geohash,conc_city,conc_state,conc_country,conc_skew,conc_density,countries,location_country,risks)\n        VALUES\n            (?,?,?,?,?,?,?,?,?,?,?,?,?) - parameters:['039e2d19-8584-40cf-...]\nsql: REPLACE INTO\n            actor_data (ip,org,client_count,types,conc_geohash,conc_city,conc_state,conc_country,conc_skew,conc_density,countries,location_country,risks)\n        VALUES\n            (?,?,?,?,?,?,?,?,?,?,?,?,?) - parameters:['039e2d19-8584-40cf-...]","time":"2023-06-15T12:39:48.414Z","v":0}
STran renamed this task from Handle `false` values in proxy field to Add fallbacks for entity properties.Jun 21 2023, 8:11 AM

Thanks! I also can't reproduce the proxy/behavior error so I think a commit has fixed it along the way ๐ŸŽ‰ . I was able to repro the error with undefined values and have update the phab task to reflect that.

This can be QAed by testing against this file (it's the fake data provided by Dom that threw these errors) and confirming that 1. it throws an error on main and 2. not on the patch and 3. 2 actors are successfully imported.

Pppery subscribed.

(actually closing)