WebThingsIO / gateway

WebThings Gateway - a self-hosted web application for monitoring and controlling a building over the web
http://webthings.io/gateway
Mozilla Public License 2.0
2.62k stars 339 forks source link

Invoking actions with units on inputs fails #3030

Open benfrancis opened 1 year ago

benfrancis commented 1 year ago

STR:

Expected:

Actual:

Error in console on server:

2022-12-07 12:51:37.374 INFO   : DeviceProxy: requestAction: advanced for: virtual-things-10
2022-12-07 12:51:37.377 ERROR  : virtual-things-adapter: AddonManagerProxy: Failed to request action advanced for device: virtual-things-10
2022-12-07 12:51:37.377 ERROR  : virtual-things-adapter: Error: strict mode: unknown keyword: "unit"
2022-12-07 12:51:37.378 ERROR  : virtual-things-adapter:     at Object.checkStrictMode (/home/tola/.nvm/versions/node/v10.24.1/lib/node_modules/gateway-addon/node_modules/ajv/dist/compile/validate/index.js:183:15)
2022-12-07 12:51:37.378 ERROR  : virtual-things-adapter:     at checkUnknownRules (/home/tola/.nvm/versions/node/v10.24.1/lib/node_modules/gateway-addon/node_modules/ajv/dist/compile/util.js:32:24)
2022-12-07 12:51:37.378 ERROR  : virtual-things-adapter:     at Object.alwaysValidSchema (/home/tola/.nvm/versions/node/v10.24.1/lib/node_modules/gateway-addon/node_modules/ajv/dist/compile/util.js:19:5)
2022-12-07 12:51:37.378 ERROR  : virtual-things-adapter:     at allProps.filter (/home/tola/.nvm/versions/node/v10.24.1/lib/node_modules/gateway-addon/node_modules/ajv/dist/vocabularies/applicator/properties.js:23:59)
2022-12-07 12:51:37.379 ERROR  : virtual-things-adapter:     at Array.filter (<anonymous>)
2022-12-07 12:51:37.379 ERROR  : virtual-things-adapter:     at Object.code (/home/tola/.nvm/versions/node/v10.24.1/lib/node_modules/gateway-addon/node_modules/ajv/dist/vocabularies/applicator/properties.js:23:37)
2022-12-07 12:51:37.379 ERROR  : virtual-things-adapter:     at Object.keywordCode (/home/tola/.nvm/versions/node/v10.24.1/lib/node_modules/gateway-addon/node_modules/ajv/dist/compile/validate/keyword.js:12:13)
2022-12-07 12:51:37.379 ERROR  : virtual-things-adapter:     at gen.block (/home/tola/.nvm/versions/node/v10.24.1/lib/node_modules/gateway-addon/node_modules/ajv/dist/compile/validate/iterate.js:54:27)
2022-12-07 12:51:37.379 ERROR  : virtual-things-adapter:     at CodeGen.code (/home/tola/.nvm/versions/node/v10.24.1/lib/node_modules/gateway-addon/node_modules/ajv/dist/compile/codegen/index.js:438:13)
2022-12-07 12:51:37.380 ERROR  : virtual-things-adapter:     at CodeGen.block (/home/tola/.nvm/versions/node/v10.24.1/lib/node_modules/gateway-addon/node_modules/ajv/dist/compile/codegen/index.js:567:18)
2022-12-07 12:51:37.380 ERROR  : Creating action advanced failed.
2022-12-07 12:51:37.381 ERROR  : undefined
benfrancis commented 1 year ago

Error: strict mode: unknown keyword: "unit"

@tim-hellhake Do you think this could be a regression caused by the TypeScript migration, with it not recognising the unit keyword on action input schemas?

benfrancis commented 1 year ago

Hmm, actually ajv is the JSON Schema validator, so maybe there's a JSON schema which isn't expecting the unit key word on action inputs.