Repository navigation
Fixes #32652: render inline MCP login errors for locked accounts and wrong passwords - #32720
Conversation
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
✅ Playwright Results — workflow succeededValidated commit ✅ 557 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky PerformanceBlocking 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:
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
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 wrongAuthenticationException. It importedorg.openmetadata.service.exception.AuthenticationException(a JAX-RSWebApplicationExceptionsubtype), but the wiredBasicAuthenticator/LdapAuthenticatorthroworg.openmetadata.service.security.AuthenticationException(an unrelatedRuntimeExceptionsubtype) fromcheckIfLoginBlocked(both providers) andBasicAuthenticator.validatePassword(Basic wrong password). Java resolvescatchtypes from the import, so the servlet's twocatch (AuthenticationException e)blocks never matched those failures and they fell through to the outercatch (Exception e), producing HTTP 500"Login processing failed"instead of re-rendering the form with a friendly inline error.I worked on this because the two
AuthenticationExceptionclasses 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:
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 toorg.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 thatBasicAuthenticator.validatePasswordalready 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
"Login blocked"(HTTP 200) instead of HTTP 500."Invalid username or password"(HTTP 200) instead of HTTP 500.org.openmetadata.service.exception.AuthenticationExceptionis 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
openmetadata-mcp/src/test/java/org/openmetadata/mcp/server/auth/handlers/BasicAuthLoginServletTest.java(3 tests).AuthenticationExceptionIS caught and renders the friendly error for both the login-blocked and wrong-password catch clauses, and the exception-packageAuthenticationExceptionis NOT caught (falls through to 500). Reverting the import makes all three tests fail; with the fix they pass.Backend integration tests
Ingestion integration tests
Playwright (UI) tests
Manual testing performed
openmetadata-mcpjar on the classpath./mcp/authorize→/mcp/login, and exercised the form."Login processing failed"(reproducing the reported bug); after the fix it returns HTTP 200 with the form containing"Invalid username or password"."Login blocked".code=…,state=…,iss=…— unchanged before and after the fix.openmetadata-mcpmodule test suite (613 tests pass) and the existing auth-handler tests.UI screen recording / screenshots:
Not applicable.
Checklist:
Fixes <issue-number>: <short explanation>.Fixes #<issue-number>above.Automatic Fixes PRs can be configured here.