Uploaded image for project: 'Debezium'
  1. Debezium
  2. DBZ-7105

When RelationalBaseSourceConnector#validateConnection is called with invalid config [inside Connector#validate()] can lead to exceptions

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 2.5.0.Alpha2
    • None
    • core-library
    • None

      In RelationalBaseSourceConnector#validate (used as Connector#validate() for relational datastore connectors) we call RelationalBaseSourceConnector#validateConnection when only some connection related config options (like hostname etc) are valid. This can lead to exceptions.

      For example when you provide a `schema.include.list` for a Postgres connector with an invalid regular expression like "+" as value but with working connection properties (which are checked in RelationalBaseSourceConnector#validate) the code assumes everything is fine to instantiate and validate the connection. But then, when instantiating an instance of the PostgresConnectorConfig the invalid regular expression gets compiled, leading to a PatternException.

      This breaks the new PostgreSQL Connect REST Extension tests and it will also break Kafka Connect's validate connector-config endpoint (PUT /connector-plugins/($connector-plugin-name)/config/validate) which will also return the exception instead of the expected response with the config definition, errors, etc.

      $ cat register-postgres-test.json 
      {
              "connector.class": "io.debezium.connector.postgresql.PostgresConnector",
              "tasks.max": "1",
              "database.hostname": "postgres",
              "database.port": "5432",
              "database.user": "postgres",
              "database.password": "postgres",
              "database.dbname" : "postgres",
              "topic.prefix": "dbserver1",
              "schema.include.list": "+"
      }
      
      $ cat register-postgres-test.json | curl -X PUT -H "Content-Type: application/json" localhost:8083/connector-plugins/PostgresConnector/config/validate --data-binary @- | jq .
      {
        "error_code": 500,
        "message": "java.util.regex.PatternSyntaxException: Dangling meta character '+' near index 0\n+\n^"
      }
      

              rk3rn3r René Kerner
              rk3rn3r René Kerner
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: