mengw15 opened a new pull request, #5164:
URL: https://github.com/apache/texera/pull/5164

   ### What changes were proposed in this PR?
   
   `GmailResource.sendEmailRequest` discarded the `Either[String, Unit]` 
returned by `sendEmail`. The endpoint itself was typed `Unit`, so JAX-RS 
responded `204 No Content` regardless of outcome — any SMTP failure (invalid 
credentials, network error, etc.) was logged server-side but the HTTP layer 
reported success, and the frontend's `next:` callback fired a green "Email sent 
successfully" toast even though no mail was delivered.
   
   This PR closes that gap in two layers:
   
   **Backend (`GmailResource.scala`)** — pattern-match the `Either` and throw 
`WebApplicationException(error, Response.Status.BAD_GATEWAY)` on `Left`. JAX-RS 
converts the exception into an HTTP 502, which triggers Angular's `error:` 
callback on the frontend side. This matches the existing codebase convention in 
`AdminUserResource` (`Email already exists`, 409) and `UserResource` (`User not 
found`, 404).
   
   **Frontend (`gmail.service.ts`)** — the existing `error:` branch only 
`console.error`'d. Add a `notificationService.error(...)` call mirroring the 
existing `notifyUnauthorizedLogin` error handler in the same file (lines 
56–61). The user-facing toast uses a generic message ("Failed to send email. 
Please try again or contact admin.") rather than the raw SMTP error, to avoid 
exposing protocol-level details like `535-5.7.8 Username and Password not 
accepted` to end users; the specific SMTP error continues to land in the 
backend log and the browser console for debugging.
   
   ### Any related issues, documentation, discussions?
   
   Closes #5161.
   
   ### How was this PR tested?
   
   Added `gmail.service.spec.ts` (Vitest + `HttpClientTestingModule`) covering 
both contracts:
   
   - HTTP 2xx → `notificationService.success("Email sent successfully")` fires
   - HTTP 502 → `notificationService.error("Failed to send email. ...")` fires
   
   No backend test added: `GmailResource` has no JAX-RS controller test 
harness, and building one would require refactoring `sendEmail` out of the 
companion object into an injectable dependency — disproportionate to a 
five-line fix.
   
   Verified locally:
   
   - `sbt "WorkflowExecutionService/scalafmtCheck" 
"WorkflowExecutionService/compile"` — clean.
   - `yarn test --include='**/gmail.service.spec.ts'` — 2 passed.
   - `yarn prettier --check src/app/common/service/gmail/gmail.service.spec.ts` 
— clean.
   
   Manual verification path (for reviewers reproducing the issue's repro):
   
   1. Don't set `USER_SYS_GOOGLE_SMTP_GMAIL` / `USER_SYS_GOOGLE_SMTP_PASSWORD`.
   2. Start amber backend + frontend.
   3. Open the share dialog on any workflow/dataset/project, enter a real 
email, submit.
   4. Frontend: red toast *"Failed to send email. Please try again or contact 
admin."*.
   5. Backend log: `Failed to send email: 535-5.7.8 Username and Password not 
accepted...` (unchanged).
   6. Browser console: `Send email error: ...` (the specific SMTP error).
   
   ### Was this PR authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (claude-opus-4-7)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to