Skip to content

feat: add MSSQL datasource configuration summary#41841

Closed
lupingblaine wants to merge 4 commits into
appsmithorg:releasefrom
lupingblaine:test/41627-null-auth-type
Closed

feat: add MSSQL datasource configuration summary#41841
lupingblaine wants to merge 4 commits into
appsmithorg:releasefrom
lupingblaine:test/41627-null-auth-type

Conversation

@lupingblaine

@lupingblaine lupingblaine commented May 22, 2026

Copy link
Copy Markdown

Summary

Adds a datasource configuration summary for successful MSSQL connection tests.

After a successful connection test, the success message now includes:

  • Database type
  • Host
  • Port
  • SSL mode
  • Authentication mode

Why

This helps users confirm which datasource configuration was tested instead of only seeing a generic success message.

Testing

  • ./build.sh -DskipTests

Summary by CodeRabbit

Release Notes

  • New Features

    • Datasource test results now display SSL configuration status and authentication type details.
    • Enhanced datasource test notifications with detailed server configuration information.
  • Improvements

    • Toast messages now properly preserve line breaks for better readability.

@coderabbitai

coderabbitai Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor

Need an answer fast? Review this PR in Change Stack to ask focused questions about the PR or a changed range.

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8350ec2a-f37d-4650-a0f7-8df27058c8b8

📥 Commits

Reviewing files that changed from the base of the PR and between 61b50f2 and ba292c7.

📒 Files selected for processing (1)
  • app/client/packages/design-system/ads/src/Toast/Toast.styles.tsx

Walkthrough

Implements MssqlPlugin.testDatasource returning DatasourceTestResult with a human-readable configuration summary (SSL/auth display lines), updates the plugin helpers and unit test to assert the additional messages, and changes the client saga to show server-provided datasource test messages in the success toast.

Changes

MSSQL plugin datasource test & summary

Layer / File(s) Summary
testDatasource entry + error mapping
app/server/appsmith-plugins/mssqlPlugin/src/main/java/com/external/plugins/MssqlPlugin.java
Adds testDatasource(DatasourceConfiguration) that creates a datasource, runs the connection test, appends configuration summary messages, ensures cleanup with doFinally(datasourceDestroy(connection)), maps plugin exceptions into DatasourceTestResult, and schedules execution on Schedulers.boundedElastic().
Configuration summary & display name helpers
app/server/appsmith-plugins/mssqlPlugin/src/main/java/com/external/plugins/MssqlPlugin.java
Adds buildDatasourceConfigurationSummary assembling ordered summary lines (database label, host:port, SSL status, authentication), plus getSslDisplayName and getAuthenticationDisplayName to format SSL/auth strings and handle null SSL authType by defaulting to DISABLE.
Updated unit test expectations
app/server/appsmith-plugins/mssqlPlugin/src/test/java/com/external/plugins/MssqlPluginTest.java
Expands the expected datasourceTestResult.getMessages() in testTestDatasource_withCorrectCredentials_returnsWithoutInvalids to include the new SSL and authentication summary lines.

Client datasource toast update

Layer / File(s) Summary
Collect and show server messages in toast
app/client/src/ce/sagas/DatasourcesSagas.ts
testDatasourceSaga collects responseData.messages when present and displays a combined success toast containing DATASOURCE_VALID plus any server-provided messages.
Toast body preserves line breaks
app/client/packages/design-system/ads/src/Toast/Toast.styles.tsx
ToastBody now uses white-space: pre-line so server-provided messages keep line breaks in toasts.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

✨ A plugin tests the DB with care,
Messages list the host and SSL flair.
Client toasts show notes, joined in line,
Tests updated to match the designed sign.
🎉 Small fixes stitched to make results align.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description covers the what and why, but is missing required template sections like Fixes, Automation, and Communication checkboxes. Complete the template by adding the issue number/URL (Fixes section) and Communication checkboxes to clarify if DevRel/Marketing should be notified.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically describes the main change: adding a MSSQL datasource configuration summary feature.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
app/server/appsmith-plugins/mssqlPlugin/src/test/java/com/external/plugins/MssqlPluginTest.java (1)

784-788: 💤 Low value

Inconsistent indentation in assertion block.

The lines inside the assertNext lambda have extra indentation. While this doesn't affect functionality, it's inconsistent with the indentation style used in other tests in this file (e.g., lines 142-146, 669-673).

♻️ Align indentation with existing test style
         StepVerifier.create(dsConnectionMono)
                 .assertNext(hikariDataSource -> {
-                        assertNotNull(hikariDataSource);
-                        assertTrue(hikariDataSource.getJdbcUrl().contains("encrypt=false"));
+                    assertNotNull(hikariDataSource);
+                    assertTrue(hikariDataSource.getJdbcUrl().contains("encrypt=false"));
                 })
                 .verifyComplete();
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@app/server/appsmith-plugins/mssqlPlugin/src/test/java/com/external/plugins/MssqlPluginTest.java`
around lines 784 - 788, The assertion block inside the Reactor test's
.assertNext lambda has extra indentation that differs from the file's standard;
locate the chain using .assertNext(hikariDataSource -> { ... }) and
.verifyComplete() and reformat the lines within the lambda (the assertNotNull
and assertTrue calls referencing hikariDataSource and
getJdbcUrl().contains("encrypt=false")) to match the surrounding test style
(remove the extra indent so the two assertions align with other tests).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@app/server/appsmith-plugins/mssqlPlugin/src/test/java/com/external/plugins/MssqlPluginTest.java`:
- Around line 776-789: The test fails because addSslOptionsToUrlBuilder(...)
throws when Connection.getSsl().getAuthType() is null; update
addSslOptionsToUrlBuilder (used by datasourceCreate(...)) to treat a null
authType as the disabled/default case (do not throw), and build the JDBC URL
with encrypt=false in that path so the test expecting "encrypt=false" passes;
also adjust the indentation of the assertions inside the assertNext(...) lambda
in MssqlPluginTest.testSslDefaultsToDisable_whenAuthTypeIsNull to align
assertNotNull(...) and assertTrue(...).

---

Nitpick comments:
In
`@app/server/appsmith-plugins/mssqlPlugin/src/test/java/com/external/plugins/MssqlPluginTest.java`:
- Around line 784-788: The assertion block inside the Reactor test's .assertNext
lambda has extra indentation that differs from the file's standard; locate the
chain using .assertNext(hikariDataSource -> { ... }) and .verifyComplete() and
reformat the lines within the lambda (the assertNotNull and assertTrue calls
referencing hikariDataSource and getJdbcUrl().contains("encrypt=false")) to
match the surrounding test style (remove the extra indent so the two assertions
align with other tests).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 41087161-9bea-49e2-999b-5521118f795d

📥 Commits

Reviewing files that changed from the base of the PR and between 3d5deb5 and 71aa71a.

📒 Files selected for processing (1)
  • app/server/appsmith-plugins/mssqlPlugin/src/test/java/com/external/plugins/MssqlPluginTest.java

@github-actions

Copy link
Copy Markdown

This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.

@github-actions github-actions Bot added the Stale label May 30, 2026
@lupingblaine lupingblaine changed the title test: add null auth type SSL fallback test feat: add MSSQL SSL fallback for missing auth type Jun 5, 2026
@lupingblaine lupingblaine changed the title feat: add MSSQL SSL fallback for missing auth type feat: add MSSQL datasource configuration summary Jun 5, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/client/src/ce/sagas/DatasourcesSagas.ts`:
- Around line 1007-1014: The toast currently passes successMessage (built via
createMessage and messages.join("\n")) as plain text to toast.show which
collapses newline characters; instead, change the call so the toast content
preserves line breaks — for example, map the messages (and
createMessage(DATASOURCE_VALID, payload.name)) into an array of React nodes and
interleave explicit line breaks (or split successMessage on "\n" and render
pieces with <br/>), then pass that ReactNode to toast.show; alternatively adjust
the toast text component (ToastBody/Text) to use CSS white-space:
pre-line/pre-wrap so newlines render—update the code paths in
DatasourcesSagas.ts around successMessage, createMessage, messages, and the
toast.show invocation accordingly.

In
`@app/server/appsmith-plugins/mssqlPlugin/src/main/java/com/external/plugins/MssqlPlugin.java`:
- Around line 410-435: The summary builder (buildDatasourceConfigurationSummary)
defaults a null SSL authType to DISABLE but that code is dead because
datasourceCreate → createConnectionPool → addSslOptionsToUrlBuilder currently
throws when authType is null; to fix, make addSslOptionsToUrlBuilder tolerate a
null SSLDetails.AuthType by removing the throw and defaulting null to
SSLDetails.AuthType.DISABLE (e.g., use ObjectUtils.defaultIfNull or equivalent
inside addSslOptionsToUrlBuilder), so createConnectionPool / datasourceCreate no
longer fail on missing authType and the summary fallback remains consistent with
connection setup.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f7b28434-0bc4-4b17-9181-11f53bd60abb

📥 Commits

Reviewing files that changed from the base of the PR and between 75e226f and 61b50f2.

📒 Files selected for processing (3)
  • app/client/src/ce/sagas/DatasourcesSagas.ts
  • app/server/appsmith-plugins/mssqlPlugin/src/main/java/com/external/plugins/MssqlPlugin.java
  • app/server/appsmith-plugins/mssqlPlugin/src/test/java/com/external/plugins/MssqlPluginTest.java

Comment thread app/client/src/ce/sagas/DatasourcesSagas.ts
Comment on lines +410 to +435
private Set<String> buildDatasourceConfigurationSummary(DatasourceConfiguration datasourceConfiguration) {
Set<String> summary = new LinkedHashSet<>();
summary.add("Summary");
summary.add("Database: MSSQL");

if (!isEmpty(datasourceConfiguration.getEndpoints())) {
Endpoint endpoint = datasourceConfiguration.getEndpoints().get(0);
summary.add("Host: " + endpoint.getHost());
summary.add("Port: " + getPort(endpoint));
}

SSLDetails.AuthType sslAuthType = datasourceConfiguration.getConnection() != null
&& datasourceConfiguration.getConnection().getSsl() != null
? datasourceConfiguration.getConnection().getSsl().getAuthType()
: null;
SSLDetails.AuthType resolvedSslAuthType =
ObjectUtils.defaultIfNull(sslAuthType, SSLDetails.AuthType.DISABLE);
summary.add("SSL: " + getSslDisplayName(resolvedSslAuthType));

DBAuth authentication = (DBAuth) datasourceConfiguration.getAuthentication();
if (authentication != null && authentication.getAuthType() != null) {
summary.add("Authentication: " + getAuthenticationDisplayName(authentication.getAuthType()));
}

return summary;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Dead code: ObjectUtils.defaultIfNull at line 426 is unreachable when authType is null.

The logic at lines 421–427 assumes sslAuthType can be null and defaults it to DISABLE for display purposes. However, buildDatasourceConfigurationSummary is only called on line 392 after datasourceCreate succeeds.

Since datasourceCreatecreateConnectionPool (line 381) → addSslOptionsToUrlBuilder (line 699) throws when authType is null (lines 721–722), a null authType will cause datasource creation to fail before this method is ever invoked.

This creates two problems:

  1. Dead code: Line 426's fallback to DISABLE can never execute when authType is actually null.
  2. Inconsistent behavior: The summary builder assumes null authType should display as "Disabled", but datasource creation rejects it with an exception.

Additionally, the PR description states this adds a "compatibility fallback for missing auth type," but the implementation at lines 721–722 does the opposite—it throws rather than falling back.

🔧 Recommended fix

Option 1 (if null authType should be supported): Remove the null check at line 722 and handle null authType in addSslOptionsToUrlBuilder by defaulting to DISABLE:

 if (datasourceConfiguration.getConnection() == null
-        || datasourceConfiguration.getConnection().getSsl() == null
-        || datasourceConfiguration.getConnection().getSsl().getAuthType() == null) {
+        || datasourceConfiguration.getConnection().getSsl() == null) {
     throw new AppsmithPluginException(...);
 }

-SSLDetails.AuthType sslAuthType =
-        datasourceConfiguration.getConnection().getSsl().getAuthType();
+SSLDetails.AuthType sslAuthType = ObjectUtils.defaultIfNull(
+        datasourceConfiguration.getConnection().getSsl().getAuthType(),
+        SSLDetails.AuthType.DISABLE);

Option 2 (if null authType should be rejected): Remove the dead defaulting logic from buildDatasourceConfigurationSummary since it can never be reached:

-SSLDetails.AuthType sslAuthType = datasourceConfiguration.getConnection() != null
-        && datasourceConfiguration.getConnection().getSsl() != null
-        ? datasourceConfiguration.getConnection().getSsl().getAuthType()
-        : null;
-SSLDetails.AuthType resolvedSslAuthType =
-        ObjectUtils.defaultIfNull(sslAuthType, SSLDetails.AuthType.DISABLE);
+// Safe to call getAuthType() without null check because datasourceCreate would have thrown otherwise
+SSLDetails.AuthType resolvedSslAuthType = 
+        datasourceConfiguration.getConnection().getSsl().getAuthType();
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@app/server/appsmith-plugins/mssqlPlugin/src/main/java/com/external/plugins/MssqlPlugin.java`
around lines 410 - 435, The summary builder
(buildDatasourceConfigurationSummary) defaults a null SSL authType to DISABLE
but that code is dead because datasourceCreate → createConnectionPool →
addSslOptionsToUrlBuilder currently throws when authType is null; to fix, make
addSslOptionsToUrlBuilder tolerate a null SSLDetails.AuthType by removing the
throw and defaulting null to SSLDetails.AuthType.DISABLE (e.g., use
ObjectUtils.defaultIfNull or equivalent inside addSslOptionsToUrlBuilder), so
createConnectionPool / datasourceCreate no longer fail on missing authType and
the summary fallback remains consistent with connection setup.

@github-actions

Copy link
Copy Markdown

This PR has been closed because of inactivity.

@github-actions github-actions Bot closed this Jun 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant