Skip to content

fix(deploy): abort restart on failure, sanitize output, fix username … - #52

Merged
gamblecodezcom merged 1 commit into
mainfrom
claude/pr52-deploy-fixes-Lq2gS
Feb 21, 2026
Merged

fix(deploy): abort restart on failure, sanitize output, fix username …#52
gamblecodezcom merged 1 commit into
mainfrom
claude/pr52-deploy-fixes-Lq2gS

Conversation

@gamblecodezcom

@gamblecodezcom gamblecodezcom commented Feb 21, 2026

Copy link
Copy Markdown
Owner

User description

…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

Summary by CodeRabbit

  • Bug Fixes

    • Fixed username/identifier validation regex pattern
    • Deployments now abort on git or npm failures instead of continuing to restart
  • Improvements

    • Enhanced formatting and truncation of deployment output messages for better readability and consistency across platforms

CodeAnt-AI Description

Abort restarts on failed deploys, trim and sanitize deploy output, and fix username detection

What Changed

  • If git pull or npm ci fails during /deploy, the bot now stops the process and does not restart; the deploy summary clearly shows "restart skipped"
  • Deployment messages sent to Telegram now strip backticks and truncate command output to 200 characters so messages render correctly and don't expose long raw output
  • Automatic username detection no longer accepts backslashes — only letters, numbers, underscore, dot, and hyphen (3–30 chars) are treated as valid usernames

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:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

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:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

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.

…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
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@codeant-ai

codeant-ai Bot commented Feb 21, 2026

Copy link
Copy Markdown

CodeAnt AI is reviewing your PR.

@coderabbitai

coderabbitai Bot commented Feb 21, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

The 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

Cohort / File(s) Summary
Sanitization Utility
index.js
Introduces sanitizeCmdOutput(str, maxLen) helper function to replace backticks with single quotes and truncate strings (default 200 chars) for safe Telegram Markdown formatting.
Deployment Flow
index.js
Integrates sanitizeCmdOutput into git pull and npm ci output handling; adds early return on deployment failure to abort further execution without proceeding to restart step.
Pattern Fixes
index.js
Corrects regex pattern from /^[A-Za-z0-9_.\\\-]{3,30}$/ to /^[A-Za-z0-9_.-]{3,30}$/, removing unnecessary backslash escape (applied in 2 locations).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 In files where Markdown flows free,
A rabbit sanitizes with glee,
Backticks to quotes, all clean and bright,
Early returns keep deploys tight,
No more messages causing a fright!


Note

🎁 Summarized by CodeRabbit Free

Your 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 @coderabbitai help to get the list of available commands and usage tips.

@gamblecodezcom
gamblecodezcom merged commit 0025ada into main Feb 21, 2026
1 of 2 checks passed
@gamblecodezcom
gamblecodezcom deleted the claude/pr52-deploy-fixes-Lq2gS branch February 21, 2026 02:30
@codeant-ai codeant-ai Bot added the size:S This PR changes 10-29 lines, ignoring generated files label Feb 21, 2026
@codeant-ai

codeant-ai Bot commented Feb 21, 2026

Copy link
Copy Markdown

Nitpicks 🔍

🔒 No security issues identified
⚡ Recommended areas for review

  • Deploy abort / notifications
    When git/npm steps fail the flow now aborts and returns (good). However the failure path only edits the status message and returns — it does not explicitly notify admins or log the failure detail beyond the edited message. Consider logging the error and notifying admins (or including more context) so operators see what failed and why.

@codeant-ai

codeant-ai Bot commented Feb 21, 2026

Copy link
Copy Markdown

CodeAnt AI finished reviewing your PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants