fix: never take RAFTER_* settings from a project .env - #265
Merged
Merged
Conversation
The working directory can be an untrusted repository, so its .env must not supply operator settings such as the API key, GitHub token, notify webhook or paid-scan confirmation. Node: the startup dotenv guard now drops every RAFTER_* variable that .env introduced, not only the disable and hook switches. Values already in the real environment are untouched. Python: resolve_key no longer calls load_dotenv(). Its upward search starts from the install path, which reaches a repository's .env when the virtualenv lives inside it. Docs no longer suggest putting the API key in .env; use the environment or the global config file.
This was referenced Oct 2, 2026
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.
Summary
A
.envin the working directory may belong to a repository the operator does not control, so it must not supply rafter's own settings.RAFTER_*variable that.envintroduced (previously onlyRAFTER_DISABLE_*andRAFTER_HOOK_*). A value already present in the real environment is untouched, and non-RAFTER_*keys still load.resolve_keyno longer callsload_dotenv(). Its search starts from the package install path, which reaches a repository's.envwhen the virtualenv lives inside that repository..env. The supported sources are--api-key, theRAFTER_API_KEYenvironment variable, and the key stored in the global~/.rafter/config.json.Behavior change
Anyone who relied on
RAFTER_API_KEY(or anotherRAFTER_*setting) in a project.envmust move it to their shell environment orrafter agent config set.The CLI then reports the key as missing instead of using the
.envvalue.Tests
node/tests/env-guard.test.ts: the case that asserted a.envRAFTER_API_KEYsurvives is replaced by one asserting.envcannot set the key, token, webhook or confirmation, while the operator's real value survives.node/tests/e2e-cli.test.ts: the dotenv e2e case now assertsrafter usageignores a.envkey and reports it missing (isolatedHOME).python/tests/test_config_secret_handling.py: a.envthat dotenv's search would find does not outrank the stored key.Each fails on
mainand passes on this branch.tscclean. Python suite: 1754 passed, 1 skipped. Node suite: 2274 passed; the 3 Cursor hook tests that fail also fail onmainin a local checkout and are unrelated.