Skip to content

Fixes #32652: render inline MCP login errors for locked accounts and wrong passwords - #32720

Merged
Vishnuujain merged 1 commit into
mainfrom
detail/bug-fix/fixes-32652-render-inline-mcp-login-errors-for-loc-e95498
Sep 7, 2026
Merged

Vishnuujain merged 1 commit into
mainfrom
detail/bug-fix/fixes-32652-render-inline-mcp-login-errors-for-loc-e95498

Conversation

@detail-app

@detail-app detail-app Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Detail bug report: View on Detail

Describe your changes:

Fixes #32652

BasicAuthLoginServlet (the browser-facing login page MCP clients redirect to when OpenMetadata runs Basic/LDAP auth) imported the wrong AuthenticationException. It imported org.openmetadata.service.exception.AuthenticationException (a JAX-RS WebApplicationException subtype), but the wired BasicAuthenticator/LdapAuthenticator throw org.openmetadata.service.security.AuthenticationException (an unrelated RuntimeException subtype) from checkIfLoginBlocked (both providers) and BasicAuthenticator.validatePassword (Basic wrong password). Java resolves catch types from the import, so the servlet's two catch (AuthenticationException e) blocks never matched those failures and they fell through to the outer catch (Exception e), producing HTTP 500 "Login processing failed" instead of re-rendering the form with a friendly inline error.

  • Locked accounts (Basic + LDAP) and Basic wrong password for an existing user got a generic 500 page, breaking the login UX for the exact normal user-error conditions the servlet was written to handle.
  • Introduced in Mcp oauth #25391 (the MCP OAuth PR), which added the servlet with the wrong import already present; the collision was set up ~10 months earlier by the Dropwizard 4.x / Jetty 11.x upgrade that created the second same-named class.

I worked on this because the two AuthenticationException classes are unrelated types that silently coexist on the classpath, so the wrong import compiles cleanly and only fails at runtime — a subtle footgun that no test caught (the servlet had zero test coverage).

Type of change:

  • Bug fix

High-level design:

N/A — small change. A single import swap in BasicAuthLoginServlet.java (1 line) plus a focused regression test. The catch clauses now resolve to org.openmetadata.service.security.AuthenticationException, so the login-blocked and Basic-wrong-password branches re-render the login form with "Login blocked" / "Invalid username or password" as intended.

Scope note (not addressed here, by design): LDAP bad-password and user-not-found for either provider still return 500 because those paths throw CustomExceptionMessage, which the servlet does not catch either before or after this change. That is a separate fix. There is also a known follow-up that BasicAuthenticator.validatePassword already records the failed attempt before throwing, so the servlet's catch block double-counts it for the Basic wrong-password path — left for a separate change to avoid regressing the null-auth-mechanism edge case.

Tests:

Use cases covered

  • Account locked from repeated failed attempts (Basic and LDAP providers) → login form re-rendered with "Login blocked" (HTTP 200) instead of HTTP 500.
  • Basic auth wrong password for an existing user → login form re-rendered with "Invalid username or password" (HTTP 200) instead of HTTP 500.
  • Valid credentials still redirect (302) to the client callback with an auth code — no regression in the success flow.
  • The unrelated JAX-RS org.openmetadata.service.exception.AuthenticationException is NOT caught by the friendly-error branches and still falls through to 500 — this pins the import to the security-package type and prevents re-introducing the wrong import.

Unit tests

  • I added unit tests for the changed logic.
  • File added: openmetadata-mcp/src/test/java/org/openmetadata/mcp/server/auth/handlers/BasicAuthLoginServletTest.java (3 tests).
  • The three tests pin the import resolution in both directions: the security-package AuthenticationException IS caught and renders the friendly error for both the login-blocked and wrong-password catch clauses, and the exception-package AuthenticationException is NOT caught (falls through to 500). Reverting the import makes all three tests fail; with the fix they pass.

Backend integration tests

  • Not applicable (no backend API endpoint changes; the servlet is internal MCP OAuth plumbing, not a JAX-RS resource).

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Not applicable (no UI changes — the login form is server-rendered HTML; the change is in error-handling, not markup).

Manual testing performed

  • Stood up MySQL 8.0 and Elasticsearch 9.3 in Docker, ran the DB migrations, and started the OpenMetadata server configured for Basic auth with the rebuilt openmetadata-mcp jar on the classpath.
  • Registered an MCP OAuth client (public, PKCE), drove /mcp/authorize → /mcp/login, and exercised the form.
  • Wrong password for an existing Basic user: with the buggy import the server returned HTTP 500 "Login processing failed" (reproducing the reported bug); after the fix it returns HTTP 200 with the form containing "Invalid username or password".
  • After enough wrong attempts to lock the account: after the fix it returns HTTP 200 with "Login blocked".
  • Valid credentials for a second (non-locked) user: 302 redirect to the client callback with code=…, state=…, iss=… — unchanged before and after the fix.
  • Confirmed no regressions by running the full openmetadata-mcp module test suite (613 tests pass) and the existing auth-handler tests.

UI screen recording / screenshots:

Not applicable.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>.
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed. (N/A — no schema changes.)
  • For UI changes: I attached a screen recording and/or screenshots above. (N/A — no UI changes.)
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • I have added a test that covers the exact scenario we are fixing.

Automatic Fixes PRs can be configured here.

@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@github-actions

github-actions Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit 841aac184c479957b215359e9d15ffc7c45e7ae9 in Playwright run 34044710454, attempt 1.

✅ 557 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky

Performance

Blocking targets: ✅ met · Optimization targets: 🟡 in progress

Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting.

🕒 Full workflow signal wall (to summary) 48m 40s

⏱️ Max setup 5m 23s · max shard execution 17m 16s · max shard-job elapsed before upload 20m 34s · reporting 4s

🌐 234.99 requests/attempt · 2.82 app boots/UI scenario · 20.46% common-shard skew

Optimization targets still in progress:

  • Common shard skew was 20.46% (convergence target: at most 15%).
  • Browser traffic was 234.99 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.82 per UI scenario (1630 boots / 578 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 140 0 0 0 0 0
✅ Shard chromium-02 124 0 0 0 0 0
✅ Shard chromium-03 135 0 0 0 0 0
✅ Shard data-asset-rules-01 65 0 0 0 0 0
✅ Shard domain-isolation-01 16 0 0 0 0 0
✅ Shard global-state-01 34 0 0 0 0 0
✅ Shard ingestion-01 1 0 0 0 0 0
✅ Shard reindex-01 2 0 0 0 0 0
✅ Shard search-01 11 0 0 0 0 0
✅ Shard search-rbac-01 29 0 0 0 0 0

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

@Vishnuujain
Vishnuujain added this pull request to the merge queue Sep 7, 2026
Merged via the queue into main with commit 7fd2c93 Sep 7, 2026
178 of 190 checks passed
@Vishnuujain
Vishnuujain deleted the detail/bug-fix/fixes-32652-render-inline-mcp-login-errors-for-loc-e95498 branch September 7, 2026 09:23

This branch was previously deployed

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

Labels

safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Detail Bug] MCP login returns HTTP 500 instead of inline errors for locked accounts and Basic-auth wrong passwords

1 participant