fix: prevent silent fallback to default value in secret resolver - #1057
Merged
Conversation
burningalchemist
force-pushed
the
fix/secret_resolver_cache
branch
from
August 11, 2026 11:12
51bfd05 to
abd6f92
Compare
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.
fixes #1056
This pull request refactors how Kubernetes and Vault secrets are fetched and resolved, improving caching and correctness when multiple jobs or references use different keys from the same secret. Now, the secret providers return the full secret payload as a JSON object, and key extraction is handled centrally (and per-call) by the resolver, ensuring consistent behavior and efficient caching. Comprehensive tests have been added for both providers and the resolver.
Secret provider refactoring and caching improvements:
config/secret_k8s.go,config/secret_vault.go: ThegetDSNmethods for both the Kubernetes and Vault secret providers now return the entire secret payload as a JSON object, rather than extracting a single key. This enables caching of the full secret and correct per-call key extraction, preventing bugs when multiple jobs use different keys from the same secret.config/secret_resolver.go: The resolver'sextractKeyfunction now parses the raw JSON payload and extracts the requested key and applies template substitution if needed, ensuring correct per-call behavior and supporting template usage.Testing improvements:
config/secret_k8s_test.go,config/secret_vault_test.go: Added comprehensive tests for both secret providers, verifying that they return the correct JSON payload, handle errors (e.g., missing secrets, non-string values), and support namespace inference and Vault engine versions.config/secret_resolver_test.go: Added a test to verify that the resolver only fetches a secret once (shared fetch) even when resolving multiple keys from the same secret, and that the correct values are returned for each key.Dependency and import updates:
These changes ensure secrets are fetched efficiently, keys are resolved correctly for each consumer, and the implementation is robustly tested.