matrix-org / matrix-appservice-irc

Node.js IRC bridge for Matrix
Apache License 2.0
462 stars 151 forks source link

config: tlsOptions property fails schema validation #1560

Closed jkhsjdhjs closed 1 week ago

jkhsjdhjs commented 2 years ago

When attempting to generate a registration file, the config is validated against its schema. This fails for me because of the following error:

The field data.ircService.servers[keys2.0].tlsOptions is null which is the wrong type
/usr/lib/node_modules/matrix-appservice-irc/node_modules/matrix-appservice-bridge/lib/components/config-validator.js:77
            throw e;
            ^

Error: Failed to validate file
    at ConfigValidator.validate (/usr/lib/node_modules/matrix-appservice-irc/node_modules/matrix-appservice-bridge/lib/components/config-validator.js:75:23)
    at Cli.loadConfig (/usr/lib/node_modules/matrix-appservice-irc/node_modules/matrix-appservice-bridge/lib/components/cli.js:184:26)
    at Cli.assignConfigFile (/usr/lib/node_modules/matrix-appservice-irc/node_modules/matrix-appservice-bridge/lib/components/cli.js:164:29)
    at Cli.run (/usr/lib/node_modules/matrix-appservice-irc/node_modules/matrix-appservice-bridge/lib/components/cli.js:140:22)
    at Object.<anonymous> (/usr/lib/node_modules/matrix-appservice-irc/app.js:79:4)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Module._load (node:internal/modules/cjs/loader:827:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47 {
  _validationErrors: [
    {
      field: 'data.ircService.servers[keys2.0].tlsOptions',
      message: 'is the wrong type',
      value: null,
      type: 'object',
      schemaPath: [
        'properties',
        'ircService',
        'properties',
        'servers',
        'additionalProperties',
        'properties',
        'tlsOptions'
      ]
    }
  ]
}

Node.js v18.0.0

The issue here is that tlsOptions isn't commented out by default, thus being present in the parent object and required to have an object as it's vaue by the schema. Commenting out tlsOptions fixes this issue.

altf4arnold commented 7 months ago

One more thing for next PR :-)