Read reward label from config instead of a crashing HTTP fetch#152
Draft
wkatir wants to merge 1 commit into
Draft
Read reward label from config instead of a crashing HTTP fetch#152wkatir wants to merge 1 commit into
wkatir wants to merge 1 commit into
Conversation
teamsBot.ts fetched a cosmetic label via getRewardName() in an unguarded async IIFE; any failure was an unhandled rejection that crashed the bot (knowall-ai#150). fetchRewardsName.ts also shipped a hardcoded auth token. The label already exists as configuration, so read it from LNBITS_POINTS_LABEL instead of over HTTP: delete fetchRewardsName.ts, read process.env.LNBITS_POINTS_LABEL in the bot and the three commands, fix the wrong REACT_APP_ var name in sendZapCommand, propagate the var via writeEnv.js, and fail loud at startup if it is unset. Supersedes knowall-ai#151. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Replaces the reward-name label mechanism. The label is now read from configuration (
LNBITS_POINTS_LABEL) instead of an HTTP fetch to a separate backend at startup. This removes the crash class in #150 at its root, deletes a hardcoded auth token, and supersedes the try/catch band-aid in #151.Type of Change
Related Issues
Fixes #150. Supersedes #151.
Changes Made
Problem
teamsBot.tsfetched a cosmetic label viagetRewardName()in an unguarded async IIFE. Any failure (backend down, port conflict) became an unhandled rejection that crashed the bot on Node >= 15.fetchRewardsName.tsalso shipped a hardcoded token ('your-secret-token').Root Cause
A cosmetic label was treated as a runtime network dependency. The label already exists as configuration (
LNBITS_POINTS_LABEL), so the fetch was both crash-prone and redundant.sendZapCommandeven readREACT_APP_LNBITS_POINTS_LABEL, which never reaches the bot process - it was alwaysundefined.Fix
src/services/fetchRewardsName.ts(removes the fetch and the hardcoded token).process.env.LNBITS_POINTS_LABELinteamsBot.tsand the three commands; fix the wrongREACT_APP_var name insendZapCommand.LNBITS_POINTS_LABELto the bot viascripts/writeEnv.js.Notes
LNBITS_POINTS_LABELis only appended toenv/.env.localon provision; existing envs must re-provision or add it manually.Screenshots (if applicable)
Not applicable - backend change (config and bot startup), no visual surface.
Test plan for QA
LNBITS_POINTS_LABELset, start the bot - it starts and cards show the label.LNBITS_POINTS_LABEL- the bot fails at startup with a clear message.Checklist
🤖 Generated with Claude Code