Claude/apply onboarding fixes r rf6 k - #32
Conversation
Update Environment_and_links.md
…n Node.js runtime, apply latest logic - Unified index.js from codex/main-m22psu (2174 lines) + all branch features merged - 2295-line final: 35-step walkthrough, full giveaway engine, 30SC wager bonus system, analytics, referral boosts, Mini App deep links, inline queries, WebApp sync - NEW commands: /play, /signup, /affiliate, /discord, /promo, /setpromo, /join - setMyCommands auto-registration with scoped admin/private/group commands - Fixed link routing: Mini App buttons (t.me/RuneWager_bot/Play|profile|claim), browser buttons for runewager.com and Discord — no user preference toggle - LINKS updated: miniAppPlay, miniAppProfile, miniAppClaim, discordSupport, runewagerProfile - promoStore now uses env vars: PROMO_CODE, PROMO_AMOUNT_SC, PROMO_CLAIM_LIMIT - BONUS_CONTACT_DISCORD env var replaces all hardcoded Discord admin IDs - Dockerfile: node:20-slim, non-root user (uid 10001), wget health check - prod-run.sh: exec node index.js only - health-check.sh: curl/wget /health endpoint, no Python - package.json: version 2.1.0, node >=20 <22 - Removed: make_gif.py, promoStore.js (state now inline) - Updated: README.md (Node.js only, full command reference) - Updated: .env.example (all env vars documented) https://claude.ai/code/session_01DuwDCiNJva2tbdiM3sBycU
|
CodeAnt AI is reviewing your PR. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughThis PR updates the project's deployment configuration, Docker setup, and documentation. Changes include reorganizing environment variables in Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
Nitpicks 🔍
|
| COPY . . | ||
| RUN chown -R runewager:runewager /app | ||
|
|
||
| RUN useradd --system --create-home --uid 10001 runewager \ |
There was a problem hiding this comment.
Suggestion: The container healthcheck and health-check.sh rely on wget (and previously relied on curl), but the new Dockerfile no longer installs any HTTP client; on a node:20-slim base image that does not include wget by default, the healthcheck will consistently fail with wget: not found even when the app is healthy. Reintroducing package installation for an HTTP client (e.g., wget) in the Docker image before dropping privileges fixes this. [possible bug]
Severity Level: Critical 🚨
- ❌ Container healthcheck fails; Docker marks service as unhealthy.
- ⚠️ Orchestrators may restart healthy containers unnecessarily.
- ⚠️ `npm run health` script uses wget/curl, also broken.| RUN useradd --system --create-home --uid 10001 runewager \ | |
| RUN apt-get update \ | |
| && apt-get install -y --no-install-recommends wget \ | |
| && rm -rf /var/lib/apt/lists/* \ | |
| && useradd --system --create-home --uid 10001 runewager \ |
Steps of Reproduction ✅
1. Build the Docker image using `/workspace/Runewager/Dockerfile` (lines 1–20), which
defines a `HEALTHCHECK` at lines 17–18 using `wget` but has no `apt-get install` for
`wget` or `curl`.
2. Run a container from this image; the container starts `node index.js` via `CMD ["node",
"index.js"]` at `Dockerfile:20` and the app exposes `GET /health` (checked by
`health-check.sh` at `/workspace/Runewager/health-check.sh:4–8` and by the Dockerfile
healthcheck URL).
3. Docker periodically executes the healthcheck command defined at `Dockerfile:17–18`:
`CMD sh -c 'wget -qO- "http://127.0.0.1:${PORT:-3000}/health" >/dev/null || exit 1'`
inside the running container.
4. Inside the container, `wget` is not installed on the `node:20-slim` base image (no
installation step in the Dockerfile), so the healthcheck command fails with `sh: 1: wget:
not found`, causing the healthcheck to exit non‑zero and the container to be marked
unhealthy even when the Node.js app is responding correctly.Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** Dockerfile
**Line:** 12:12
**Comment:**
*Possible Bug: The container healthcheck and `health-check.sh` rely on `wget` (and previously relied on `curl`), but the new Dockerfile no longer installs any HTTP client; on a `node:20-slim` base image that does not include `wget` by default, the healthcheck will consistently fail with `wget: not found` even when the app is healthy. Reintroducing package installation for an HTTP client (e.g., `wget`) in the Docker image before dropping privileges fixes this.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.| const BOT_TOKEN = process.env.BOT_TOKEN; | ||
| const ADMIN_IDS = (process.env.ADMIN_IDS || '') | ||
| .split(',') | ||
| .map((id) => id.trim()) | ||
| .filter(Boolean) | ||
| .map((id) => Number(id)); | ||
|
|
||
| if (!BOT_TOKEN) { |
There was a problem hiding this comment.
Suggestion: The bot now only reads BOT_TOKEN and no longer falls back to TELEGRAM_BOT_TOKEN as before, so existing deployments that still provide only TELEGRAM_BOT_TOKEN will crash at startup with "Missing BOT_TOKEN" even though a valid token is configured. [possible bug]
Severity Level: Critical 🚨
- ❌ Bot fails to start in TELEGRAM_BOT_TOKEN-only setups.
- ❌ All Telegram onboarding and giveaway features unavailable.| const BOT_TOKEN = process.env.BOT_TOKEN; | |
| const ADMIN_IDS = (process.env.ADMIN_IDS || '') | |
| .split(',') | |
| .map((id) => id.trim()) | |
| .filter(Boolean) | |
| .map((id) => Number(id)); | |
| if (!BOT_TOKEN) { | |
| const BOT_TOKEN = process.env.BOT_TOKEN || process.env.TELEGRAM_BOT_TOKEN; | |
| const ADMIN_IDS = (process.env.ADMIN_IDS || '') | |
| .split(',') | |
| .map((id) => id.trim()) | |
| .filter(Boolean) | |
| .map((id) => Number(id)); | |
| if (!BOT_TOKEN) { | |
| throw new Error('Missing BOT_TOKEN (or TELEGRAM_BOT_TOKEN) in environment variables.'); |
Steps of Reproduction ✅
1. Configure an environment where only `TELEGRAM_BOT_TOKEN` is set (and not `BOT_TOKEN`),
matching the legacy configuration expected by the pre-PR code (see old code in the diff
where `BOT_TOKEN` was derived from `process.env.BOT_TOKEN ||
process.env.TELEGRAM_BOT_TOKEN`).
2. Start the Node.js process that runs `index.js`; on load, the config block at
`index.js:11-20` executes `const BOT_TOKEN = process.env.BOT_TOKEN;` which resolves to
`undefined` because `BOT_TOKEN` is not set.
3. The subsequent guard at `index.js:18-20` (`if (!BOT_TOKEN) { throw new Error('Missing
BOT_TOKEN in environment variables.'); }`) evaluates to true and throws, causing the
process to terminate before `new Telegraf(BOT_TOKEN)` at `index.js:55` or `startBot()` at
`index.js:2047+` can run.
4. Observe that the Telegram bot never launches (no polling/webhook setup, no health log
messages), and all Telegram commands and callbacks defined throughout `index.js` remain
unreachable because the process exits during configuration.Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** index.js
**Line:** 11:18
**Comment:**
*Possible Bug: The bot now only reads `BOT_TOKEN` and no longer falls back to `TELEGRAM_BOT_TOKEN` as before, so existing deployments that still provide only `TELEGRAM_BOT_TOKEN` will crash at startup with "Missing BOT_TOKEN" even though a valid token is configured.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.| remainingClaims: Number(process.env.PROMO_CLAIM_LIMIT) || 600, | ||
| get bonusRule() { return `Wager 3,000 SC in any rolling 7-day period → 30 SC bonus (once per account). Contact ${process.env.BONUS_CONTACT_DISCORD || 'the GambleCodez Discord admin'}.`; }, |
There was a problem hiding this comment.
Suggestion: The promo bonus description is defined as a read-only getter (get bonusRule() { ... }) but later updated via assignment (promoStore.bonusRule = text in the admin flow), so the admin /setpromo path will silently fail to change the displayed bonus rule and users will still see the old text. [logic error]
Severity Level: Major ⚠️
- ⚠️ /promo output ignores admin-updated bonus rule text.
- ⚠️ Claim flow shows outdated wagering/bonus instructions.| remainingClaims: Number(process.env.PROMO_CLAIM_LIMIT) || 600, | |
| get bonusRule() { return `Wager 3,000 SC in any rolling 7-day period → 30 SC bonus (once per account). Contact ${process.env.BONUS_CONTACT_DISCORD || 'the GambleCodez Discord admin'}.`; }, | |
| bonusRule: process.env.PROMO_BONUS_RULE | |
| || `Wager 3,000 SC in any rolling 7-day period → 30 SC bonus (once per account). Contact ${process.env.BONUS_CONTACT_DISCORD || 'the GambleCodez Discord admin'}.`, |
Steps of Reproduction ✅
1. Start the bot with the current PR code (`index.js`), ensuring an admin Telegram ID is
configured in `ADMIN_IDS` so `/setpromo` is available (see admin commands setup at
`index.js:453-496` and `bot.command('setpromo', ...)` at `index.js:712-718`).
2. As an admin user in a private chat with the bot, send the `/setpromo` command; this is
handled at `index.js:712-718`, which sets `user.pendingAction = { type:
'admin_set_bonus_rule' }`.
3. Reply in the same chat with a new promo bonus description text (for example, changing
the contact handle or wagering conditions); the text handler at `index.js:1485-1500`
matches `action.type === 'admin_set_bonus_rule'` and executes `promoStore.bonusRule =
text`.
4. Trigger the user-facing promo view by issuing `/promo` (handled at `index.js:704-710`)
or using the "How to Claim" button, which calls `promoText()` at `index.js:228-230`;
`promoText()` still reads `promoStore.bonusRule` from the getter defined at
`index.js:60-70`, so the displayed bonus rule remains the original hard-coded string and
ignores the admin-provided text.Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** index.js
**Line:** 66:67
**Comment:**
*Logic Error: The promo bonus description is defined as a read-only getter (`get bonusRule() { ... }`) but later updated via assignment (`promoStore.bonusRule = text` in the admin flow), so the admin `/setpromo` path will silently fail to change the displayed bonus rule and users will still see the old text.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.|
CodeAnt AI finished reviewing your PR. |
CodeAnt-AI Description
Use HTTP health endpoint, require Node 20, non-root Docker user, and update start scripts/docs
What Changed
Impact
✅ Clearer setup and startup instructions✅ Health checks work reliably inside containers✅ Lower privilege container runtime (non-root user)💡 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.
Summary by CodeRabbit
New Features
Documentation
Chores