feat(bundle): graceful handling of missing secrets in env var processor#26
Open
deluxetom wants to merge 2 commits into
Open
feat(bundle): graceful handling of missing secrets in env var processor#26deluxetom wants to merge 2 commits into
deluxetom wants to merge 2 commits into
Conversation
Missing secrets now throw Symfony's EnvNotFoundException (manager and key in the message, original SecretNotFoundException as previous) instead of leaking the raw exception, which also lets the built-in default: processor compose. Opt in to warning-plus-null resolution per reference with the new secretaryOptional:/secretaryArrayOptional: prefixes, or globally with the allow_missing_secrets bundle config. Only SecretNotFoundException is handled; other adapter errors still bubble up. Closes #25 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…y/config Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
cryptiklemur
approved these changes
Jul 7, 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.
Closes #25
Implements the design agreed in #25 (comment), test-first (TDD).
What changed
Default: better error, still exceptional.
EnvVarProcessornow catchesSecretNotFoundExceptionand rethrows Symfony'sEnvNotFoundExceptionwith the manager name and secret key in the message and the original exception asprevious. As a bonus, Symfony's built-indefault:processor now composes:%env(default:fallback_param:secretary:default:KEY)%.Per-reference opt-in. New
secretaryOptional:andsecretaryArrayOptional:prefixes log a warning through the injected PSR-3 logger and resolvenullwhen the secret is missing.Global opt-in. New
allow_missing_secretsbundle config (defaults tofalse) applies the same warning +nullbehavior to all secretary prefixes.Logging. The processor takes an optional
Psr\Log\LoggerInterface(wired to theloggerservice withIGNORE_ON_INVALID_REFERENCE,NullLoggerfallback), so monolog is not required.psr/logadded to the bundle and monorepo composer.json.Note
Only
SecretNotFoundExceptiongets this treatment — network, auth, and other adapter errors still bubble up unchanged.Tests (written first, watched fail, then implemented)
EnvNotFoundExceptionwith manager + key +previoussecretaryOptional:/secretaryArrayOptional:→ warning +nullallow_missing_secrets: true→ warning +nullon standard prefixesnull(NullLogger fallback)getProvidedTypes()exposes the new prefixesloggerreference +allow_missing_secretsflag passed throughvendor/bin/phpunit: 44 tests green across Core/Adapters/Bundle.composer ecsandcomposer psalmclean.🤖 Generated with Claude Code