-
Notifications
You must be signed in to change notification settings - Fork 781
feat(wren-ui): support MySQL ssl #1698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe changes introduce SSL configuration support for MySQL data sources. The MySQL connection info interface is updated to include an Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant UI (MySQLProperties)
participant Server (dataSource)
participant Repository
User->>UI (MySQLProperties): Toggle "Use SSL" switch
UI (MySQLProperties)->>Server (dataSource): Submit form with ssl value
Server (dataSource)->>Repository: Store/retrieve MYSQL_CONNECTION_INFO with ssl
Server (dataSource)->>Server (dataSource): Transform connection info, set sslMode
Poem
✨ 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:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
wren-ui/src/apollo/server/dataSource.ts
(1 hunks)wren-ui/src/apollo/server/repositories/projectRepository.ts
(1 hunks)wren-ui/src/components/pages/setup/dataSources/MySQLProperties.tsx
(2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: narsik123
PR: Canner/WrenAI#1606
File: wren-ui/src/apollo/server/dataSource.ts:135-150
Timestamp: 2025-04-28T20:09:06.106Z
Learning: The Oracle data source implementation has an inconsistency: the OracleProperties UI component includes an SSL toggle switch, but the ORACLE_CONNECTION_INFO interface doesn't include an ssl property. This means the SSL setting in the UI has no effect on the actual connection. The interface should be updated to include ssl:boolean, and the implementation should use the pattern `...(ssl && { kwargs: { ssl: true } })` for handling SSL.
🧬 Code Graph Analysis (1)
wren-ui/src/apollo/server/dataSource.ts (2)
wren-ui/src/apollo/server/repositories/projectRepository.ts (1)
MYSQL_CONNECTION_INFO
(27-34)wren-ui/migrations/20240530062809_transfer_project_table_data.js (1)
ssl
(40-41)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
🔇 Additional comments (4)
wren-ui/src/apollo/server/repositories/projectRepository.ts (1)
33-33
: Excellent consistency improvement!Adding the
ssl
boolean property to theMYSQL_CONNECTION_INFO
interface aligns with the pattern used by other database connection interfaces (PostgreSQL, ClickHouse, Trino). This creates uniformity across database types that support SSL configuration.wren-ui/src/components/pages/setup/dataSources/MySQLProperties.tsx (2)
1-1
: LGTM: Clean import additionAdding the
Switch
component import is appropriate for the SSL toggle functionality.
92-94
: LGTM: Proper SSL toggle implementationThe SSL form item is correctly implemented with:
- Proper
valuePropName="checked"
for boolean form binding- Form field name "ssl" that matches the interface property
- Consistent styling with other form items
This follows Ant Design best practices for boolean form controls.
wren-ui/src/apollo/server/dataSource.ts (1)
126-126
: LGTM: Proper destructuring updateAdding
ssl
to the destructuring assignment correctly extracts the SSL configuration from the connection info.
return { | ||
host, | ||
port, | ||
database, | ||
user, | ||
password, | ||
sslMode: ssl ? 'ENABLED' : 'DISABLED', | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Verify the sslMode field format with backend expectations
The SSL handling logic is clean and follows a clear boolean-to-string mapping. However, the MySQL implementation uses a different approach compared to other databases (PostgreSQL uses URL parameters, ClickHouse uses URL parameters, Trino uses protocol switching).
Please verify that the sslMode
field with 'ENABLED'
/'DISABLED'
values matches what the MySQL backend/driver expects for SSL configuration.
🏁 Script executed:
#!/bin/bash
# Description: Search for sslMode usage patterns in the codebase to verify the expected format
# Expected: Find references to sslMode field usage in MySQL-related code
echo "Searching for sslMode usage patterns..."
rg -A 3 -B 3 "sslMode" --type ts --type js
echo -e "\nSearching for MySQL SSL configuration patterns..."
rg -A 5 -B 5 "ENABLED|DISABLED" --type ts --type js | grep -i -A 5 -B 5 "mysql\|ssl"
echo -e "\nSearching for MySQL connection configuration..."
rg -A 10 "mysql.*connection" --type ts --type js -i
Length of output: 11966
Fix MySQL sslMode mapping to valid Connector/J values
The MySQL Connector/J driver uses the sslMode
property (not useSSL
) and only accepts specific string values (e.g. DISABLED
, PREFERRED
, REQUIRED
, VERIFY_CA
, VERIFY_IDENTITY
). The current code maps ssl
to "ENABLED"
/"DISABLED"
, but "ENABLED"
is not a supported mode. Please update this to one of the valid modes—typically REQUIRED
when SSL must be on—and verify against your backend’s expectations:
• File: wren-ui/src/apollo/server/dataSource.ts
Change around line 130:
- sslMode: ssl ? 'ENABLED' : 'DISABLED',
+ sslMode: ssl ? 'REQUIRED' : 'DISABLED', // use a valid Connector/J sslMode value
See MySQL Connector/J docs for the full list of sslMode options and adjust as needed.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
return { | |
host, | |
port, | |
database, | |
user, | |
password, | |
sslMode: ssl ? 'ENABLED' : 'DISABLED', | |
}; | |
return { | |
host, | |
port, | |
database, | |
user, | |
password, | |
sslMode: ssl ? 'REQUIRED' : 'DISABLED', // use a valid Connector/J sslMode value | |
}; |
🤖 Prompt for AI Agents
In wren-ui/src/apollo/server/dataSource.ts around lines 128 to 135, the sslMode
field is currently set to 'ENABLED' or 'DISABLED', but MySQL Connector/J expects
specific sslMode values such as 'DISABLED', 'PREFERRED', 'REQUIRED',
'VERIFY_CA', or 'VERIFY_IDENTITY'. Replace the 'ENABLED' string with 'REQUIRED'
when ssl is true to match valid Connector/J options, and keep 'DISABLED' when
ssl is false. Verify this change aligns with backend SSL requirements.
Description
In this PR, we support SSL mode for MySQL data source.
The CA mode is not supported currently.
Issue related
#1024
Summary by CodeRabbit
New Features
Enhancements