domains / cloud-infra / pallets/flask
Document environment config scope
When documenting or introducing configuration mechanisms (env files, env vars, build/tox flags, config options), be explicit about what each mechanism is for, where it applies, and what is safe to commit to version control. Specifically:
When documenting or introducing configuration mechanisms (env files, env vars, build/tox flags, config options), be explicit about what each mechanism is for, where it applies, and what is safe to commit to version control. Specifically:
- Never present secrets (API keys, passwords, credentials) and non-sensitive, shareable settings (like app entry points) as if they belong in the same file/mechanism. If an example shows a
.envfile, make clear whether it’s meant to be committed or git-ignored, and warn that mixing secrets into a committed file is a common source of leaks. - Clearly state the scope of a configuration mechanism: e.g.,
.envfiles are only loaded byflask run/flask shellvia the CLI, not in production WSGI servers like gunicorn — so don’t imply it solves production configuration too. Prefer scoped, environment-aware defaults (e.g., a committedwsgi.pyentry point) over relying on uncommitted files for values needed in both dev and prod. - Keep configuration examples and documented types/options accurate and specific to the tool/version in question (e.g.,
tag_svn_revisiononly works with SVN — usetag_build/tag_datefor generic dev builds; don’t widen a documented config type likePERMANENT_SESSION_LIFETIMEtofloatjust because it happens to work — document the intended, supported type). - When adding environment-conditional settings (e.g., tox dependency markers), verify that default/common workflows (like
tox -e py) still work unmodified, and document any special syntax (such as negation markers) since such conventions are often poorly documented elsewhere.
Example of a safer pattern instead of relying solely on .env for app location:
# wsgi.py (safe to commit)
from myapp import create_app
application = create_app()
This avoids encouraging users to store FLASK_APP/secrets together in an uncommitted file while still giving a simple, committed entry point for both dev and production.</description>
</invoke>