fix: support special chars in password and exit on auth failure#34
Merged
Conversation
Two fixes: 1. Add ROCKETCHAT_BOT_PASSWORD_FILE env var support (Docker _FILE pattern). Reads password from a file, avoiding shell/env escaping issues with characters like #, $, &, (, ), etc. 2. Exit immediately on authentication errors (401, User not found, IP blocked) instead of retrying with backoff. Prevents the bot account from being temporarily locked due to rapid retries. Also: document the _FILE option in .env.example and README.md. Closes #33
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.
Problem
1. Password special characters cause silent truncation
When the bot password contains
#,&,(,), etc. in the.envfile, Docker Compose treats#as a comment (truncating the password) and shell interpretation can mangle other characters.2. Auth failure triggers rapid retry loop → account locked
When login fails (wrong password/user not found), the bot retries with backoff, triggering Rocket.Chat's IP-based rate limiting and locking the account.
Fix
Fix 1 —
ROCKETCHAT_BOT_PASSWORD_FILEenv varAdded support for the Docker-native
_FILEsecret pattern: ifROCKETCHAT_BOT_PASSWORDis empty, the bot reads fromROCKETCHAT_BOT_PASSWORD_FILEinstead (file content is trimmed). This avoids all shell/env escaping issues.Fix 2 — Exit on auth error (no retry)
Added
isAuthError()helper checking for 401, User not found, IP blocked. Both the initialConnect()and the reconnect loop now exit immediately with a clear message instead of retrying.Files Changed
internal/config/config.go_FILEenv var patterninternal/rocket/client.goisAuthError(), exit on auth failure.env.exampleROCKETCHAT_BOT_PASSWORD_FILEdocumentationREADME.md_FILEto env vars tableCloses #33