fix(secret-resolver): update secret resolver logic when set SERVICE_BINDING_ROOT#121
Draft
cassiofariasmachado wants to merge 2 commits into
Draft
fix(secret-resolver): update secret resolver logic when set SERVICE_BINDING_ROOT#121cassiofariasmachado wants to merge 2 commits into
cassiofariasmachado wants to merge 2 commits into
Conversation
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.
Description
Fixes the secret resolver so that applications deployed in environments following the servicebinding.io spec can load service bindings without manual configuration.
Problem: When
SERVICE_BINDING_ROOTis set, the resolver looked for secrets at$ROOT/<module>/<instance>/<field>(three levels). The servicebinding.io spec mandates a flat two-level layout:$ROOT/<binding-name>/<field>. This causedcreate_client()to fail with a path-not-found error for any binding mounted under the flat convention, including the Agent Memory service.Fix: When
SERVICE_BINDING_ROOTis explicitly set, the resolver now tries the flat path$ROOT/<module>/<field>first (servicebinding.io spec), then falls back to the legacy three-level path$ROOT/<module>/<instance>/<field>(existing AppFND convention), and finally falls back to environment variables. WhenSERVICE_BINDING_ROOTis not set, only the legacy path is tried — no behaviour change for existing deployments.The fix is applied centrally in
read_from_mount_and_fallback_to_env_var, so all SDK modules (Agent Memory, Audit Log, Destination, Object Store, DMS) benefit automatically.The internal refactor extracts
_load_from_path(secret_dir, target)from_load_from_mountso both code paths share identical file-reading logic with no duplication.Related Issue
N/A
Type of Change
How to Test
create_client()(e.g. Agent Memory) in an environment whereSERVICE_BINDING_ROOTis set and the binding is mounted flat at$SERVICE_BINDING_ROOT/<binding-name>/<field>.AgentMemoryConfigErrorand can make requests.To test locally with unit tests:
Key new test cases:
test_service_binding_root_flat_path_success— flat path is tried first whenSERVICE_BINDING_ROOTis settest_service_binding_root_flat_fails_falls_back_to_module_instance— graceful fallback to legacy layout when flat files are absenttest_service_binding_root_overrides_base_mount— verifies the flat path is now the first attemptChecklist
Additional Notes
The fallback is safe for environments that set
SERVICE_BINDING_ROOTbut use the older three-level layout: the flat attempt finds the parent directory but fails to read the field files (which live in the<instance>/subdirectory), so the resolver silently falls through to the legacy path.