Repository navigation
docs: .env.example with the Slack setup steps, and degrade instead of dying on bad Slack settings - #2
Merged
Merged
Conversation
Three things came out of setting Slack up against a real workspace. A misconfigured optional notifier could stop the program from logging: a malformed credential raised out of the first log call and killed the process. The handler already refuses to let a dead webhook do that, so a typo in the same feature should not either. Slack is now switched off and the reason written once at CRITICAL; log_dir and level still raise, since there is nothing sensible to fall back to there. LoggerConfig.slack_problem() is the check. Setting names are checked by Logger() and configure() rather than where they are resolved. Resolution is lazy, so configure(load_env=True) used to fail at the first log call with a traceback pointing at a line that was perfectly correct. Near misses are now suggested, e.g. did you mean load_dotenv. chat.postMessage payloads carry a top-level text field as well as the attachment. Without it the push notification and sidebar preview arrive blank. Also: comments removed from the source, with the two load-bearing ones folded into docstrings; a README appendix on inviting the bot to the channel, which is the most common reason a correct-looking setup delivers nothing, along with the error codes that distinguish it and the "# common" copy-paste trap. Verified: 153 tests on 3.8/3.9/3.12, pre-commit clean, wheel builds, every README example executed, and alerts confirmed arriving in a real Slack channel. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Setting this up from the README means reading prose and remembering which steps apply. A template that is already in the right shape removes that: copy it, delete what you do not need, fill in the rest. The Slack section carries its setup steps inline, with the one everyone skips called out where it cannot be missed -- inviting the bot to the channel. It also records the two traps that cost real time: adding a scope needs a reinstall, which issues a new token; and Slack's UI draws a channel as "# common" with a space that is not part of the name. .env.example is committed and .env is gitignored, so the template can drift away from the code without anyone noticing. Four tests stop that: every variable it names must be one the code reads, every variable the code reads must appear in it, its uncommented lines must produce a usable config, and no value in it may look like a real token. Writing them turned up that the variable names were spelled out inline in from_env, so they now come from one ENV_KEYS mapping that both the loader and the tests use. Verified: 161 tests on 3.8/3.9/3.12, pre-commit clean, wheel builds. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Follow-up to #1, from setting Slack up against a real workspace. Two commits.
docs: add .env.example(a3c74c5)Setting this up from the README means reading prose and remembering which steps apply to you. A template that is already the right shape removes that: copy it, delete what you do not need, fill in the rest.
Every variable with its default, and the Slack section carries its setup steps inline — with the one everyone skips called out where it cannot be missed: inviting the bot to the channel. It also records the two traps that cost real time here:
# common, with a space that is not part of the name.env.exampleis committed while.envis gitignored, so the template can drift away from the code with nothing to catch it. Four tests stop that: every variable it names must be one the code reads, every variable the code reads must appear in it, its uncommented lines must produce a usable config, and no value in it may look like a real token. Writing them turned up that the variable names were spelled out inline infrom_env, so they now come from oneENV_KEYSmapping used by both the loader and the tests.The README also gains an appendix, the bot must be in the channel — the most common reason a correct-looking setup delivers nothing — with a table separating
not_in_channelfromchannel_not_found,missing_scope,invalid_authandis_archived.fix: degrade on bad Slack settings(89ed739)A misconfigured optional notifier could stop the program from logging. A malformed credential raised out of the first log call and killed the process. The handler already refuses to let a dead webhook do that, so a typo in the same feature should not either.
Slack is now switched off and the reason written once at
CRITICAL:log_dirandlevelstill raise — there is nothing sensible to fall back to there.LoggerConfig.slack_problem()is the check, and credentials never appear in it.Setting names are checked by
Logger()andconfigure()rather than where they are resolved. Resolution is lazy, soconfigure(load_env=True)used to fail at the first log call, with a traceback pointing at a line that was perfectly correct. Near misses are now suggested:chat.postMessagepayloads carry a top-leveltextas well as the attachment. Without it the push notification and sidebar preview arrive blank.Comments are also gone from the source, with the two load-bearing ones folded into docstrings: the
stackleveloffset (a wrapper added above_emitwould silently pointoriginatlogger.py) and why the bot-token path reads the response body.Verification
pre-commit run --all-filesclean;uv buildproduces a wheel that imports from a clean environment🤖 Generated with Claude Code