Skip to content

Source Clickhouse: Fix exception in case password field is not provided in configuration #10214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Feb 16, 2022

Conversation

CrafterKolyan
Copy link
Contributor

@CrafterKolyan CrafterKolyan commented Feb 9, 2022

What

Fixes exception in case password is not provided for Clickhouse source.

Clickhouse source specification doesn't require password.
Config example:

{
    "host": "127.0.0.1",
    "port": 8123,
    "database": "default",
    "username": "default",
    "ssl": false,
    "tunnel_method": {
        "tunnel_method": "NO_TUNNEL"
    }
}

This leads to the following exception

Exception while checking connection:
java.lang.NullPointerException: Cannot invoke "com.fasterxml.jackson.databind.JsonNode.asText()" because the return value of "com.fasterxml.jackson.databind.JsonNode.get(String)" is null
        at io.airbyte.integrations.source.clickhouse.ClickHouseSource.toDatabaseConfig(ClickHouseSource.java:98) ~[io.airbyte.airbyte-integrations.connectors-source-clickhouse-0.35.1-alpha.jar:?]
        at io.airbyte.integrations.source.jdbc.AbstractJdbcSource.createDatabase(AbstractJdbcSource.java:282) ~[io.airbyte.airbyte-integrations.connectors-source-jdbc-0.35.1-alpha.jar:?]
        at io.airbyte.integrations.source.jdbc.AbstractJdbcSource.createDatabase(AbstractJdbcSource.java:62) ~[io.airbyte.airbyte-integrations.connectors-source-jdbc-0.35.1-alpha.jar:?]
        at io.airbyte.integrations.source.relationaldb.AbstractDbSource.createDatabaseInternal(AbstractDbSource.java:490) ~[io.airbyte.airbyte-integrations.connectors-source-relational-db-0.35.1-alpha.jar:?]
        at io.airbyte.integrations.source.relationaldb.AbstractDbSource.check(AbstractDbSource.java:65) ~[io.airbyte.airbyte-integrations.connectors-source-relational-db-0.35.1-alpha.jar:?]
        at io.airbyte.integrations.base.ssh.SshTunnel.sshWrap(SshTunnel.java:205) [io.airbyte.airbyte-integrations.bases-base-java-0.35.1-alpha.jar:?]
        at io.airbyte.integrations.base.ssh.SshWrappedSource.check(SshWrappedSource.java:37) [io.airbyte.airbyte-integrations.bases-base-java-0.35.1-alpha.jar:?]
        at io.airbyte.integrations.base.IntegrationRunner.run(IntegrationRunner.java:102) [io.airbyte.airbyte-integrations.bases-base-java-0.35.1-alpha.jar:?]
        at io.airbyte.integrations.source.clickhouse.ClickHouseSource.main(ClickHouseSource.java:111) [io.airbyte.airbyte-integrations.connectors-source-clickhouse-0.35.1-alpha.jar:?]

Steps to reproduce

  1. Save config example as config.json
  2. docker run --rm -i -v config.json:/tmp/config.json airbyte/source-clickhouse check --config /tmp/config.json
    Actual:
  3. Receive an exception above
    Expected:
  4. Receive an exception Connection refused or something like that (if you don't have a running copy of Clickhouse)

How

Simply checking if the password field is provided.
The same way as it is done in PostgresSource.

final ImmutableMap.Builder<Object, Object> configBuilder = ImmutableMap.builder()
.put("username", config.get("username").asText())
.put("jdbc_url", jdbcUrl.toString());
if (config.has("password")) {
configBuilder.put("password", config.get("password").asText());
}
return Jsons.jsonNode(configBuilder.build());

🚨 User Impact 🚨

No breaking changes

Pre-merge Checklist

Expand the relevant checklist and delete the others.

Updating a connector

Community member or Airbyter

  • Grant edit access to maintainers (instructions)
  • Secrets in the connector's spec are annotated with airbyte_secret
  • Unit & integration tests added and passing. Community members, please provide proof of success locally e.g: screenshot or copy-paste unit, integration, and acceptance test output. To run acceptance tests for a Python connector, follow instructions in the README. For java connectors run ./gradlew :airbyte-integrations:connectors:<name>:integrationTest.
  • Code reviews completed
  • Documentation updated
    • Connector's README.md
    • Connector's bootstrap.md. See description and examples
    • Changelog updated in docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
  • PR name follows PR naming conventions

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • Credentials added to Github CI. Instructions.
  • /test connector=connectors/<name> command is passing.
  • New Connector version released on Dockerhub by running the /publish command described here
  • After the new connector version is published, connector version bumped in the seed directory as described here
  • Seed specs have been re-generated by building the platform and committing the changes to the seed spec files, as described here

Exception while checking connection:
java.lang.NullPointerException: Cannot invoke "com.fasterxml.jackson.databind.JsonNode.asText()" because the return value of "com.fasterxml.jackson.databind.JsonNode.get(String)" is null
        at io.airbyte.integrations.source.clickhouse.ClickHouseSource.toDatabaseConfig(ClickHouseSource.java:98) ~[io.airbyte.airbyte-integrations.connectors-source-clickhouse-0.35.1-alpha.jar:?]
        at io.airbyte.integrations.source.jdbc.AbstractJdbcSource.createDatabase(AbstractJdbcSource.java:282) ~[io.airbyte.airbyte-integrations.connectors-source-jdbc-0.35.1-alpha.jar:?]
        at io.airbyte.integrations.source.jdbc.AbstractJdbcSource.createDatabase(AbstractJdbcSource.java:62) ~[io.airbyte.airbyte-integrations.connectors-source-jdbc-0.35.1-alpha.jar:?]
        at io.airbyte.integrations.source.relationaldb.AbstractDbSource.createDatabaseInternal(AbstractDbSource.java:490) ~[io.airbyte.airbyte-integrations.connectors-source-relational-db-0.35.1-alpha.jar:?]
        at io.airbyte.integrations.source.relationaldb.AbstractDbSource.check(AbstractDbSource.java:65) ~[io.airbyte.airbyte-integrations.connectors-source-relational-db-0.35.1-alpha.jar:?]
        at io.airbyte.integrations.base.ssh.SshTunnel.sshWrap(SshTunnel.java:205) [io.airbyte.airbyte-integrations.bases-base-java-0.35.1-alpha.jar:?]
        at io.airbyte.integrations.base.ssh.SshWrappedSource.check(SshWrappedSource.java:37) [io.airbyte.airbyte-integrations.bases-base-java-0.35.1-alpha.jar:?]
        at io.airbyte.integrations.base.IntegrationRunner.run(IntegrationRunner.java:102) [io.airbyte.airbyte-integrations.bases-base-java-0.35.1-alpha.jar:?]
        at io.airbyte.integrations.source.clickhouse.ClickHouseSource.main(ClickHouseSource.java:111) [io.airbyte.airbyte-integrations.connectors-source-clickhouse-0.35.1-alpha.jar:?]
@CLAassistant
Copy link

CLAassistant commented Feb 9, 2022

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added the area/connectors Connector related issues label Feb 9, 2022
@github-actions github-actions bot added the area/documentation Improvements or additions to documentation label Feb 9, 2022
@CrafterKolyan
Copy link
Contributor Author

CrafterKolyan commented Feb 9, 2022

By the way don't see anything for source-clickhouse-strict-encrypt. Can't understand how to change its version.

UPD: Found it

Copy link
Member

@marcosmarxm marcosmarxm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcosmarxm marcosmarxm self-assigned this Feb 9, 2022
@marcosmarxm marcosmarxm temporarily deployed to more-secrets February 16, 2022 00:53 Inactive
@marcosmarxm marcosmarxm temporarily deployed to more-secrets February 16, 2022 00:53 Inactive
@github-actions github-actions bot removed area/server CDK Connector Development Kit labels Feb 16, 2022
@marcosmarxm marcosmarxm merged commit 22810c3 into airbytehq:master Feb 16, 2022
@marcosmarxm marcosmarxm temporarily deployed to more-secrets February 16, 2022 16:07 Inactive
@marcosmarxm marcosmarxm temporarily deployed to more-secrets February 16, 2022 16:07 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/connectors Connector related issues area/documentation Improvements or additions to documentation community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants