Skip to content

Attach connection error to CONNECTION_URL#1626

Open
Praveen Kumar G (pgajendran-confluent) wants to merge 2 commits intomasterfrom
fix-cc-40873
Open

Attach connection error to CONNECTION_URL#1626
Praveen Kumar G (pgajendran-confluent) wants to merge 2 commits intomasterfrom
fix-cc-40873

Conversation

@pgajendran-confluent
Copy link
Copy Markdown
Member

Problem

JdbcSinkConnectorValidation.validateConnection() catches database connection errors (e.g., SSL failures) but silently drops them because it tries to attach the error to connection.host, which is not defined in JdbcSinkConfig.CONFIG_DEF.

connection.host is a connect-templates variable, not a native kafka-connect-jdbc config. The configValue() helper returns Optional.empty() and the ifPresent callback never fires — the error is logged but never added to the validation result.

Solution

Attach the connection error to CONNECTION_URL (connection.url) instead of CONNECTION_HOST (connection.host), since connection.url IS defined in CONFIG_DEF.

Does this solution apply anywhere else?
  • yes
  • no
If yes, where?

Test Strategy

Testing done:
  • Unit tests
  • Integration tests
  • System tests
  • Manual tests

Release Plan

Copilot AI review requested due to automatic review settings April 20, 2026 15:14
@confluent-cla-assistant
Copy link
Copy Markdown

🎉 All Contributor License Agreements have been signed. Ready to merge.
Please push an empty commit if you would like to re-run the checks to verify CLA status for all contributors.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes sink connector validation so database connection failures are surfaced in the returned config validation results by attaching the error to a real config key.

Changes:

  • Switch validation error attachment from connection.host (not in JdbcSinkConfig.CONFIG_DEF) to connection.url (defined).
  • Update static import to use JdbcSinkConfig.CONNECTION_URL.
Comments suppressed due to low confidence (1)

src/main/java/io/confluent/connect/jdbc/validation/JdbcSinkConnectorValidation.java:112

  • validateConnection() catches Exception, but the log line hard-codes "SQLException during validation". Either narrow the catch to SQLException (and handle other exceptions separately) or update the log message to reflect that any exception type may be thrown here.
      configValue(validationResult, CONNECTION_URL)
          .ifPresent(hostName ->
              hostName.addErrorMessage(
                  String.format("Could not connect to database. %s", e.getMessage())));
      log.error("SQLException during validation", e);
    }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 109 to 110
hostName.addErrorMessage(
String.format("Could not connect to database. %s", e.getMessage())));
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

Including the raw exception message (e.getMessage()) in the connector validation error can leak sensitive connection details (some JDBC drivers include the full URL and credentials in exception messages). Consider using a generic message (and optionally include only non-sensitive fields like exception class and/or SQLState when e is a SQLException) while keeping the full exception details in logs.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.
Are there any existing UTs to test it?

@pgajendran-confluent
Copy link
Copy Markdown
Member Author

LGTM. Are there any existing UTs to test it?

Thanks. No UTs currently to test it though.

@sangeet259
Copy link
Copy Markdown
Member

Can you raise the PR against the earliest feature branch in which the issue is present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants