feat(dashboard): add SSL config validation to prevent saving invalid HTTPS settings#5516
feat(dashboard): add SSL config validation to prevent saving invalid HTTPS settings#5516YukiRa1n wants to merge 3 commits intoAstrBotDevs:masterfrom
Conversation
…TTPS settings When users enable WebUI HTTPS without configuring certificate and key file paths, the server would fail to start on the next launch. This fix adds: - Backend validation in save_config() to reject invalid SSL configurations - Frontend validation in ConfigPage.vue to provide immediate user feedback - i18n translations for the validation error message in both zh-CN and en-US
Use semicolon-separated string instead of Python list format for better readability in error messages.
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the WebUI configuration by introducing robust validation for HTTPS settings. The primary goal is to prevent server startup failures that occur when users enable SSL without providing the necessary certificate and key files. By implementing both backend and frontend validation, the system now proactively checks for complete SSL configurations, improving stability and user experience, and includes internationalization for error messages. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Hey - 我提供了一些高层面的反馈:
- SSL 校验规则目前同时实现于后端的
validate_ssl_config和前端的validateSslConfig中;建议把这些规则(或者至少条件/文案)集中到同一个地方,以避免它们随着时间推移出现不一致。 - 后端的
validate_ssl_config返回的是硬编码的中文错误字符串,然后再包装到通用的ValueError中;你可以考虑统一使用适合 i18n 的键/消息,或者使用专门的校验错误类型,这样调用方就能更好地区分不同错误并以一致的方式展示。
给 AI Agents 的提示
Please address the comments from this code review:
## Overall Comments
- The SSL validation rules are implemented both in `validate_ssl_config` on the backend and `validateSslConfig` on the frontend; consider centralizing the rules (or at least the conditions/messages) in one place to avoid them drifting out of sync over time.
- Backend `validate_ssl_config` returns hardcoded Chinese error strings and then wraps them in a generic `ValueError`; you may want to either standardize on i18n-friendly keys/messages or use a dedicated validation error type so the caller can distinguish and present errors consistently.帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的评审。
Original comment in English
Hey - I've left some high level feedback:
- The SSL validation rules are implemented both in
validate_ssl_configon the backend andvalidateSslConfigon the frontend; consider centralizing the rules (or at least the conditions/messages) in one place to avoid them drifting out of sync over time. - Backend
validate_ssl_configreturns hardcoded Chinese error strings and then wraps them in a genericValueError; you may want to either standardize on i18n-friendly keys/messages or use a dedicated validation error type so the caller can distinguish and present errors consistently.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The SSL validation rules are implemented both in `validate_ssl_config` on the backend and `validateSslConfig` on the frontend; consider centralizing the rules (or at least the conditions/messages) in one place to avoid them drifting out of sync over time.
- Backend `validate_ssl_config` returns hardcoded Chinese error strings and then wraps them in a generic `ValueError`; you may want to either standardize on i18n-friendly keys/messages or use a dedicated validation error type so the caller can distinguish and present errors consistently.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Code Review
This pull request introduces validation for SSL configuration on both the backend and frontend, which is a great addition to prevent server startup failures due to invalid HTTPS settings. The implementation is solid, with checks in config.py and ConfigPage.vue, along with i18n support for error messages. I have one suggestion to enhance the backend validation by checking for the existence of the certificate and key files, which would more robustly prevent the issue described.
Motivation / 动机
This PR adds validation for WebUI HTTPS configuration to prevent users from saving invalid SSL settings that would cause the server to fail on startup.
该 PR 添加了 WebUI HTTPS 配置验证,防止用户保存无效的 SSL 设置导致服务器启动失败。
Problem / 问题描述:
When users enable
dashboard.ssl.enablewithout configuringcert_fileandkey_file, the server fails to start on next launch with SSL certificate loading errors.当用户启用
dashboard.ssl.enable但未配置cert_file和key_file时,服务器下次启动时会因 SSL 证书加载错误而失败。Modifications / 改动点
Backend Validation / 后端验证
validate_ssl_config()function inastrbot/dashboard/routes/config.pydashboard.ssl.enableistrue, bothcert_fileandkey_filemust be configuredFrontend Validation / 前端验证
validateSslConfig()method indashboard/src/views/ConfigPage.vuei18n Support / 国际化支持
zh-CNanden-USlocale filesBreaking Changes
Verification / 验证步骤
dashboard.ssl.enablecert_fileandkey_fileempty修改之前
修改之后

Checklist / 检查清单
requirements.txt和pyproject.toml文件相应位置。/ I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations inrequirements.txtandpyproject.toml.Summary by Sourcery
为仪表盘的 HTTPS 配置添加验证,防止保存会导致服务器无法启动的 SSL 设置。
新功能:
增强:
Original summary in English
Summary by Sourcery
Add validation around dashboard HTTPS configuration to prevent saving SSL settings that would break server startup.
New Features:
Enhancements: