Copilot commented on code in PR #5164:
URL: https://github.com/apache/texera/pull/5164#discussion_r3292423695
##########
amber/src/main/scala/org/apache/texera/web/resource/GmailResource.scala:
##########
@@ -146,7 +147,11 @@ class GmailResource {
@Path("/send")
def sendEmailRequest(emailMessage: EmailMessage, @Auth user: SessionUser):
Unit = {
val recipientEmail = if (emailMessage.receiver.isEmpty) user.getEmail else
emailMessage.receiver
- sendEmail(emailMessage, recipientEmail)
+ sendEmail(emailMessage, recipientEmail) match {
+ case Right(_) => ()
+ case Left(error) =>
+ throw new WebApplicationException(error, Response.Status.BAD_GATEWAY)
+ }
Review Comment:
Throwing `WebApplicationException(error, ...)` will propagate the raw SMTP
exception message back to the client in the HTTP response payload (and thus to
the browser console). If the goal is only to trigger the frontend error path,
consider returning a generic error message in the response body and logging the
detailed SMTP failure server-side to avoid leaking protocol/internal details to
end users.
##########
amber/src/main/scala/org/apache/texera/web/resource/GmailResource.scala:
##########
@@ -146,7 +147,11 @@ class GmailResource {
@Path("/send")
def sendEmailRequest(emailMessage: EmailMessage, @Auth user: SessionUser):
Unit = {
val recipientEmail = if (emailMessage.receiver.isEmpty) user.getEmail else
emailMessage.receiver
- sendEmail(emailMessage, recipientEmail)
+ sendEmail(emailMessage, recipientEmail) match {
+ case Right(_) => ()
Review Comment:
`sendEmail` can return `Left("Invalid email format")` for client-provided
bad addresses, but this code maps *all* `Left`s to HTTP 502. That makes invalid
input look like an upstream/gateway failure. Consider mapping validation
failures to 400 (e.g., `BadRequestException`) and reserving 502 for
SMTP/Transport failures (ideally by returning a typed error instead of a
string).
--
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]