fix(deploy): abort restart on failure, sanitize output, fix username … - #52
Conversation
…regex Addresses all PR #51 CodeAnt AI review comments: 1. Critical 🚨 — /deploy now aborts restart when git pull or npm ci fail. Previously the bot restarted unconditionally, potentially loading broken code. Now an early return is taken with a clear "restart skipped" message so the host stays on the last known-good version. 2. Sanitize deploy output sent to Telegram — new sanitizeCmdOutput() helper strips backtick characters (which break Markdown code spans) and truncates to 200 chars before embedding git/npm output in bot messages. Prevents Telegram parse errors and avoids leaking raw long error text. 3. Fix username detection regex — /^[A-Za-z0-9_.\\-]{3,30}$/ contained a double-backslash that matched literal '\' characters in usernames. Corrected to /^[A-Za-z0-9_.-]{3,30}$/ — only alphanumerics, underscore, dot, and hyphen are accepted. 4. prod-run.sh systemctl audit — all three call sites are already consistently guarded (ensure_systemd_service, restart block, diagnostics). No changes needed; confirmed safe on non-systemd hosts. https://claude.ai/code/session_01X3PxGFF5zzKptQwVkjYzzN
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
CodeAnt AI is reviewing your PR. |
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughThe changes add a sanitizeCmdOutput helper function to format command outputs for Telegram messages, integrate it into the deployment flow to sanitize git and npm outputs, implement early failure handling to prevent execution continuation on errors, and correct a regex pattern by removing an unnecessary backslash escape. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
Nitpicks 🔍
|
|
CodeAnt AI finished reviewing your PR. |
User description
…regex
Addresses all PR #51 CodeAnt AI review comments:
Critical 🚨 — /deploy now aborts restart when git pull or npm ci fail. Previously the bot restarted unconditionally, potentially loading broken code. Now an early return is taken with a clear "restart skipped" message so the host stays on the last known-good version.
Sanitize deploy output sent to Telegram — new sanitizeCmdOutput() helper strips backtick characters (which break Markdown code spans) and truncates to 200 chars before embedding git/npm output in bot messages. Prevents Telegram parse errors and avoids leaking raw long error text.
Fix username detection regex — /^[A-Za-z0-9_.\-]{3,30}$/ contained a double-backslash that matched literal '' characters in usernames. Corrected to /^[A-Za-z0-9_.-]{3,30}$/ — only alphanumerics, underscore, dot, and hyphen are accepted.
prod-run.sh systemctl audit — all three call sites are already consistently guarded (ensure_systemd_service, restart block, diagnostics). No changes needed; confirmed safe on non-systemd hosts.
https://claude.ai/code/session_01X3PxGFF5zzKptQwVkjYzzN
Summary by CodeRabbit
Bug Fixes
Improvements
CodeAnt-AI Description
Abort restarts on failed deploys, trim and sanitize deploy output, and fix username detection
What Changed
Impact
✅ Avoids restarts into broken code✅ Fewer Telegram parse errors from deploy output✅ Fewer incorrect username matches💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.