fix: smtp without username password#39987
Conversation
…sue-39965/smtp-without-username-password
WalkthroughThe changes modify the SMTP plugin by conditionally setting the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant SMTPPlugin
participant SMTPTransport
Client->>SMTPPlugin: testDatasource(datasourceConfiguration)
SMTPPlugin->>SMTPPlugin: createProperties(datasourceConfiguration)
SMTPPlugin->>SMTPTransport: attempt connection (with auth if credentials provided)
alt Authentication succeeds
SMTPTransport-->>SMTPPlugin: Connection established
else Authentication fails
SMTPTransport-->>SMTPPlugin: Authentication error
SMTPPlugin->>SMTPTransport: retry connection without auth
end
SMTPTransport-->>SMTPPlugin: Return connection status/error
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms (2)
🔇 Additional comments (3)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Pull Request Overview
This PR fixes SMTP authentication issues when no username or password is provided and improves related error handling and configuration clarity.
- Updated SMTP properties to delay setting auth until credentials are verified.
- Modified the testDatasource method to recreate the session based on datasource configuration with proper fallback logic.
- Introduced a helper method createProperties to centralize property construction.
Comments suppressed due to low confidence (1)
app/server/appsmith-plugins/smtpPlugin/src/main/java/com/external/plugins/SmtpPlugin.java:278
- Ensure that the transport connection is closed after a successful connect to prevent potential resource leaks. Consider invoking transport.close() in a finally block or using a try-with-resources pattern if applicable.
transport.connect();
| } catch (MessagingException e) { | ||
| log.error(e.getMessage()); | ||
| invalids.add(SMTPErrorMessages.DS_CONNECTION_FAILED_TO_SMTP_SERVER_ERROR_MSG); | ||
| invalids.add(e.getMessage()); |
There was a problem hiding this comment.
Consider standardizing the error message to provide more context rather than using the raw exception message, to help users better understand the failure.
|
/build-deploy-preview skip-tests=true |
|
Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/14172310831. |
|
Deploy-Preview-URL: https://ce-39987.dp.appsmith.com |
|
Closing this PR as the actual cause of the issue was the property |
Description
Fixes #39965
Automation
/ok-to-test tags="@tag.Datasource"
🔍 Cypress test results
Caution
If you modify the content in this section, you are likely to disrupt the CI result for your PR.
Communication
Should the DevRel and Marketing teams inform users about this change?
Summary by CodeRabbit
Bug Fixes
Refactor