Repository navigation
[2.0] Fixes #38023: preserve 424 FAILED_SEND_EMAIL in signup/password-reset flows (backport 2.0 #38051) - #38232
Conversation
… flows (#38051) * fix(auth): preserve raw HTTP status for non-enum codes in WebServiceException * test(auth): assert persisted password on reset email-failure path Address greptile feedback on BasicAuthenticatorEmailFailureTest: capture the User handed to createOrUpdate and verify it carries a BCrypt hash of the requested new password, so the test fails if the password is never set on the saved user (instead of relying solely on createOrUpdate being called). --------- Co-authored-by: detail-app[bot] <180357370+detail-app[bot]@users.noreply.github.com> (cherry picked from commit 2cc8c55)
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
| public WebServiceException(Response.Status status, String errorType, String message) { | ||
| super(message); | ||
| this.status = status; | ||
| this.statusCode = status.getStatusCode(); | ||
| this.errorType = errorType; | ||
| this.message = message; | ||
| } | ||
|
|
||
| public WebServiceException(int status, String errorType, String message) { | ||
| super(message); | ||
| this.statusCode = status; | ||
| this.errorType = errorType; | ||
| this.message = message; | ||
| } | ||
|
|
||
| public WebServiceException( |
There was a problem hiding this comment.
💡 Edge Case: Enum ctor now NPEs on null status from fromStatusCode callers
The Response.Status constructors now call status.getStatusCode() as soon as the exception is built (lines 21, 36). Some callers still pass Response.Status.fromStatusCode(response.statusCode()), for example AirflowRESTClient.clientException(...) (line ~913) and IngestionPipelineDeploymentException.byMessage(...) (line ~413). That call returns null for any code missing from the enum, such as 422 or 424 from Airflow. Before this PR the exception was still created and failed later in getResponse(). Now new PipelineServiceClientException(...) throws an NPE inside the client code, so the Airflow error message is lost. The catch (PipelineServiceClientException) handlers in MeteredPipelineServiceClient and IngestionPipelineRepository are also skipped. This is the same non-enum-status bug the PR fixes, still present on the enum path. Fix: make the enum constructors null-safe, or give those callers int overloads that pass response.statusCode() directly.
Fall back to 500 when a null enum status is passed instead of NPE-ing at construction:
public WebServiceException(Response.Status status, String errorType, String message) {
this(toStatusCode(status), errorType, message);
}
private static int toStatusCode(Response.Status status) {
return status == null
? Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()
: status.getStatusCode();
}
Was this helpful? React with 👍 / 👎
Code Review 👍 Approved with suggestions 🟡 Medium risk 0 closed / 1 findingsPreserving raw status codes changes signup and password-reset email failures from 500 to 424, which may alter client error handling. Preserves the raw int HTTP status in 💡 Edge Case: Enum ctor now NPEs on null status from fromStatusCode callers📄 openmetadata-spec/src/main/java/org/openmetadata/sdk/exception/WebServiceException.java:19-33 The Fall back to 500 when a null enum status is passed instead of NPE-ing at construction🤖 Prompt for agentsVerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
| @Test | ||
| void basicAuthEmailFailureConstantsRenderAs424() { | ||
| Response response = | ||
| new CatalogGenericExceptionMapper() | ||
| .toResponse( | ||
| new CustomExceptionMessage(424, "FAILED_SEND_EMAIL", "Email sending issue")); | ||
|
|
||
| assertEquals(424, response.getStatus()); | ||
| JsonNode body = JsonUtils.valueToTree(response.getEntity()); | ||
| assertEquals(424, body.path("code").asInt()); | ||
| assertEquals("Email sending issue", body.path("message").asText()); |
There was a problem hiding this comment.
Duplicate tests add no coverage. Both mapper tests pass the same exception with the same literal values and check the same response. The second test does not use the constants its name promises to check. Keep one test, or make the second exercise a distinct case. The repository guide says copy-pasted logic must be shared rather than duplicated.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| ArgumentCaptor<User> savedUser = ArgumentCaptor.forClass(User.class); | ||
| verify(userRepository) | ||
| .createOrUpdate(nullable(UriInfo.class), savedUser.capture(), anyString()); | ||
| User persisted = savedUser.getValue(); | ||
| assertNotNull(persisted.getAuthenticationMechanism(), "auth mechanism must be set"); | ||
| BasicAuthMechanism config = | ||
| (BasicAuthMechanism) persisted.getAuthenticationMechanism().getConfig(); | ||
| assertNotNull(config, "basic-auth config must be set on the persisted user"); | ||
| assertTrue( | ||
| BCrypt.verifyer() | ||
| .verify("Password123!".toCharArray(), config.getPassword().toCharArray()) | ||
| .verified, | ||
| "the persisted password must be a BCrypt hash of the requested new password"); | ||
| verify(tokenRepository) | ||
| .deleteTokenByUserAndType(user.getId(), TokenType.PASSWORD_RESET.toString()); |
There was a problem hiding this comment.
Tests mock internal storage. The new tests replace
UserRepository, TokenRepository, and Entity, then use verify() to claim that passwords and tokens were saved or removed. Inspecting the captured user proves the hash was prepared, not that it was stored. The repository guide says to mock boundaries, not internal classes, and to check database state rather than internal calls. Move these storage checks into integration tests with real repositories; keep the email failure at the boundary.
Context Used: AGENTS.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| assertTrue( | ||
| outputStream.content().contains("Email sending issue"), | ||
| "the failure message must reach the client"); |
There was a problem hiding this comment.
Repeated strings need constants. The added check passes a raw string to
contains(). The same email message and error name are also repeated across the new tests. The repository guide forbids raw strings in contains() and requires named constants for repeated strings. Use the existing email-error constants and shared test values where appropriate.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| public WebServiceException(int status, String errorType, String message) { | ||
| super(message); | ||
| this.statusCode = status; | ||
| this.errorType = errorType; | ||
| this.message = message; |
There was a problem hiding this comment.
Unchanged values lack final. The new constructor parameters and new test locals are never reassigned but omit
final. The repository guide requires final on parameters and local variables that do not change. Apply it to the new declarations; the mapper test's response and body are two more examples.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Backport of #38051 to
2.0. Issue: #38023.What
CustomExceptionMessage(int, ...)coerced the status throughResponse.Status.fromStatusCode(...), which returnsnullfor codes outside the enum (424). The null status madeWebServiceException.getResponse()throwIllegalArgumentExceptioninside the exception mapper, so the basic-auth email-failure paths (signup, resend registration token, password reset) answered a generic 500 with an empty body.WebServiceExceptionnow keeps the raw int status code, so they answer 424 again.Differences from the main PR
CatalogGenericExceptionMapperTestdoes not exist on 2.0 (cherry-pick conflict); it is added here with only the two tests from Fixes #38023: preserve 424 FAILED_SEND_EMAIL in signup/password-reset flows #38051.WebServiceExceptionbody as{code, message}— the typederrorTypebody (ADR 2026-11-14 typed client errors) is a later main/2.1 change and is not backported. So 2.0 returns 424 withouterrorType: FAILED_SEND_EMAIL; the mapper test asserts the 424 status,codeandmessageaccordingly. The 2.0 UI keys this flow on the 424 status (HTTP_STATUS_CODE.FAILED_DEPENDENCY), not onerrorType.Tests
SecurityUtilTest,BasicAuthenticatorEmailFailureTest,CatalogGenericExceptionMapperTest,CustomExceptionMessageTest— Tests run: 66, Failures: 0, Errors: 0.spotless:checkclean.WebServiceException/CustomExceptionMessage, new tests kept): all 6 new tests fail withResponse status must not be 'null'(Tests run: 60, Failures: 1, Errors: 5).🤖 Generated with Claude Code
Satisfy the repository's test and style requirements before merging; no blocking runtime defect was found in the email-status fix.
Findings
Summary
This backport preserves HTTP 424 when signup or password-reset emails fail, while keeping the 2.0 response body unchanged.
Reviews (1) · Last reviewed commit: "Fixes #38023: preserve 424 FAILED_SEND_E..." · Reviewed by Greptile