Skip to content

Bug #83023, keep the server cause in the XMLA Test Connection message - #9204

Merged
NeverStopFMH merged 2 commits into
mainfrom
bug-83023
Dec 2, 2026
Merged

NeverStopFMH merged 2 commits into
mainfrom
bug-83023

Conversation

@Nelson-cao

Copy link
Copy Markdown
Contributor

Problem

XMLA data source Test Connection (POST api/portal/data/datasource/xmla/test) showed the same "Failed to connect to datasource [x]! Please check the connection information." for a wrong catalog on a reachable endpoint and for an unreachable server. The server's cause was dropped.

Root cause

XmlaDatasourceService.testConnect caught every Exception and always set common.datasource.connectFailed with only the data source name, discarding the exception message. In addition, XMLAHandler.testDataSource reported an empty catalog result with the generic failedConnectDB text.

Fix

  • testConnect: an IOException anywhere in the cause chain (refused, unknown host, timeout, bad URL) keeps connectFailed. Any other exception means the endpoint answered, so the status is the new common.datasource.xmla.endpointError ("The XMLA endpoint of datasource [X] answered with an error: (check the catalog name, the URL path and the credentials)"). A blank message falls back to connectFailed. connected stays false.
  • XMLAHandler.testDataSource: a named catalog with an empty Discover result throws the new common.datasource.xmla.catalogNotFound ("Catalog [X] was not found on the XMLA server.").
  • Keys added to srinter.properties and community-examples/localize/srinter_en_US.properties; other locales fall back to the base bundle.
  • No handler change was needed for the eMondrian fault body: its <detail><Error Description=...> is already thrown by SAXHandler.startElement on the Discover path, so the cause reaches testConnect (proved by the new test, which failed before the fix).

Tests run

XmlaDatasourceServiceTestConnectTest (new, raw-socket stub): 5 run, 0 failed (3 failed on the unfixed code: eMondrian-shaped 200 fault, empty rowset, HTTP 500). Also run together: XMLAHandlerReasonPhraseTest 3, XMLAHandlerRequestEscapingTest 23, SrinterMessageFormatQuotesTest 10, MDXHelperDrillThroughRequestTest 3, DataSourceRegistryConnectionTestQueryTest 22: all green (66 total).

Known limits

  • DataSourceStatusService (167-220) matches "username"/"password" in the handler message, so surfacing server text can change which status text a data source shows (text only).
  • The wiz branch (stylebi-wiz-main-rebase) needs a separate port; not done here.
  • Not covered: HTTP 500 fault body is not parsed (message keeps the HTTP 500 prefix only); the null/empty-catalog multi-catalog case is a separate defect.

🤖 Generated with Claude Code

Nelson-cao and others added 2 commits December 2, 2026 19:33
Test Connection showed the generic connect-failed text for an unreachable server and for a reachable endpoint that answered with an error (wrong catalog). A connection-level failure (IOException in the cause chain) keeps that text; an answer from the endpoint now reports its cause, and an empty catalog result names the catalog.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Nelson-cao

Copy link
Copy Markdown
Contributor Author

Review round 1 of PR 9204, head 7200ae0. Verdict: clean (no blocker, no important); three nits recorded, none sent back to the fixer.

Checked against the confirmed cause (testConnect dropped the server's text for every failure):

  • Classification: an IOException anywhere in the cause chain (UnknownHost, Connect, SocketTimeout, SSL handshake, MalformedURL, all IOException subclasses) keeps the connect-failed text. The chain walk stops on a self-cause, and a null message also falls back to the old text. HTTP non-200 (actionErr "HTTP "), <Error Description>, failedConnectDB, parser errors on a non-XML 200 body are RuntimeException/SAXException, so they are reported as "endpoint answered" with the cause. Correct for every XMLAHandler.testDataSource path.
  • Empty-catalog check: getCatalogs(catalogName) sends a CATALOG_NAME restriction, so an empty result for a named catalog means the server answered without it; a server that ignores the restriction and returns several catalogs still lands in the old failedConnectDB branch, which now surfaces as endpointError. No literal from the repro is keyed on; the test constants are only in the test.
  • Catalog keys: apostrophe-free, {0}/{1} well formed, added to srinter.properties and the en_US examples bundle; fr/ja/zh bundles do not need them (fallback to the base bundle). SrinterMessageFormatQuotesTest green per fix notes.
  • UI: Portal shows connection.status through the message dialog ([innerHTML]="message", Angular-sanitized, so no script execution) or a notification. The text comes from the endpoint the same user configured, so no new information exposure.
  • Dependent tests: Grep of both repos' test trees for XmlaDatasourceService, testConnect, failedConnectDB, connectFailed, XMLAHandler: only the XMLAHandler tests (reason phrase, escaping, drill-through) and the new test; none asserts the old text.
  • Test quality: raw-socket stub on an ephemeral port, closed in @AfterEach, daemon accept thread, @Tag("core") with the Spring context, 5 cases covering 200 fault / 200 empty / 500 / unreachable / success.
  • precommit-check (community, base origin/main): exit 0, no findings.

Nits (not blocking): (1) callSoap0 wraps a failed getInputStream after a 200 into a cause-less RuntimeException, so such a read failure would read as "answered with an error"; extremely rare. (2) createDataSource errors with a message (not IOException) would also be labelled as endpoint answered. (3) The message dialog renders the server text as sanitized HTML, so markup in a server error would display as markup.

@Nelson-cao

Copy link
Copy Markdown
Contributor Author

Live verification at head 7200ae0: built onto the shared instance and re-ran the Test Connection reproduction (REST and the Portal dialog) against an eMondrian-shaped stub. A wrong catalog now shows the endpoint-answered text with Unknown catalog 'NoSuchCatalog'; the control still passes; an unreachable port and an unknown host still show the connection-failure text. Targeted tests: 6 classes, 66 cases, all pass.

@NeverStopFMH NeverStopFMH 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.

Verdict

Ready to merge. No blocking issues.

Open verdicts from the conversation

none. The only conversation entries are two comments from Nelson-cao (review round 1: clean, three nits; live verification at head 7200ae0). There are no CHANGES REQUESTED reviews and no inline comments.

Committed secrets

none (scanned the net patch and both commits, 315b1b6 and 7200ae0; only message strings, test XML and a loopback socket).

Tests run

no trigger fired. Community PR; the new test is tagged core, which CI's core-tests jobs run. The PR body's test list is a report, not a "must pass" demand (C2). I did not build the change.

Findings

Blocking: none.

Non-blocking:

  1. XmlaDatasourceService.isConnectionFailure treats any IOException in the cause chain as "unreachable". A server that answers but sends a truncated or malformed body also throws IOException (for example a SAX-over-stream read error), so it keeps the generic text. This is acceptable and matches the PR's stated intent.
  2. In XMLAHandler.testDataSource, the case of more than one catalog returned (server ignores the CATALOG_NAME restriction) still throws failedConnectDB. testConnect now shows it as "endpoint answered with an error: ", which reads slightly redundant. Cosmetic.
  3. The endpointError text embeds the raw server message (fault string or HTTP code). This goes to an admin-only Test Connection dialog and is rendered as text. Risk is low, but the message is not truncated. A very long or HTML body could produce a long status.
  4. New keys exist only in the base srinter.properties and en_US. The fr_FR and zh_CN bundles fall back to English, as the PR states.
  5. The test builds CredentialService by reflection and uses a raw socket stub. It is a bit heavy but deterministic: it binds to loopback, uses daemon threads and closes the socket in @AfterEach. No test elsewhere asserts the old connectFailed or failedConnectDB text for XMLA, and the existing XMLAHandler*Test classes do not touch testDataSource.

Backward compatibility: testDataSource still throws RuntimeException in the same situations; only the message text differs. testConnect keeps connected=false and the same connectFailed text for connection-level failures. A blank message falls back to the old text.

@NeverStopFMH
NeverStopFMH merged commit 1b13090 into main Dec 2, 2026
4 checks passed
@NeverStopFMH
NeverStopFMH deleted the bug-83023 branch December 2, 2026 12:09
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.

2 participants