Skip to content

fix: load ProjectConfiguration deploy-config from .env (#1970)#1971

Merged
davidpoblador merged 1 commit into
mainfrom
worktree-fix-projectconfig-env-file
Jun 2, 2026
Merged

fix: load ProjectConfiguration deploy-config from .env (#1970)#1971
davidpoblador merged 1 commit into
mainfrom
worktree-fix-projectconfig-env-file

Conversation

@davidpoblador

Copy link
Copy Markdown
Member

Summary

Fixes #1970. ProjectConfiguration did not set env_file in its model_config, so deploy-time fields that live on it (notably from_email) could not be configured via a .env file in development. They only resolved from:

  • real OS environment variables (works in Docker/prod), or
  • .copier-answers.yml, where non-template keys are silently stripped on copier update — a fragile home for deploy config.

Every sibling settings class (CoreConfiguration, MailSettings, BrandSettings, RateLimitSettings, LocaleDetectionSettings, SecurityHeadersSettings) already declares env_file=_ENV_FILES. This change brings ProjectConfiguration in line, so FROM_EMAIL=... in .env works in dev as the docs already describe.

Change

  • config.py: add env_file=_ENV_FILES to ProjectConfiguration.model_config.

Tests

Added TestProjectConfigurationEnvFile in test_config.py:

  • test_declares_env_file — guards the model_config wiring (fails on main, passes here).
  • test_from_email_loads_from_dotenvfrom_email is read from a .env file.
  • test_from_email_falls_back_to_default — default preserved with no .env/env var.

Verified the structural test fails before the fix and passes after.

Precedence note

When ProjectConfiguration is built from .copier-answers.yml via ProjectConfiguration(**yaml_data), init kwargs remain the highest-priority source — so a from_email present in .copier-answers.yml still wins over .env. The .env value applies precisely when the key is absent from the questionnaire, which is the scenario the issue wants.

Docs

No doc change: FROM_EMAIL in .env is already documented (authentication.md, deployment.md, llms-full.txt). This fix makes the code honor the existing docs.

🤖 Generated with Claude Code

ProjectConfiguration omitted env_file from its model_config, so deploy-time
fields like from_email could not be set via a .env file in development. They
only resolved from real OS environment variables (Docker/prod) or from
.copier-answers.yml, where non-template keys are silently stripped on copier
update.

Add env_file=_ENV_FILES to ProjectConfiguration.model_config, matching every
sibling settings class (CoreConfiguration, MailSettings, BrandSettings,
RateLimitSettings, LocaleDetectionSettings, SecurityHeadersSettings). This
makes the .env usage already documented for FROM_EMAIL work in dev too.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@davidpoblador davidpoblador merged commit 13b67a7 into main Jun 2, 2026
2 checks passed
@davidpoblador davidpoblador deleted the worktree-fix-projectconfig-env-file branch June 2, 2026 15:45
davidpoblador pushed a commit that referenced this pull request Jun 2, 2026
🤖 I have created a release *beep* *boop*
---


##
[10.22.4](v10.22.3...v10.22.4)
(2026-06-02)


### Bug Fixes

* fast-path worker-health to skip CLI bootstrap
([#1974](#1974))
([#1977](#1977))
([ee77f6c](ee77f6c))
* load ProjectConfiguration deploy-config from .env
([#1970](#1970))
([#1971](#1971))
([13b67a7](13b67a7))
* negotiate Accept-Language with language-only subtag fallback
([#1973](#1973))
([#1975](#1975))
([0738181](0738181))


### Documentation Updates

* warn that backgrounded SSE tabs drop events and document resync
([#1978](#1978))
([6bb1a91](6bb1a91))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ProjectConfiguration can't be configured via .env — deploy-config fields forced into the copier questionnaire

1 participant