fix(agent-memory): use secret resolver public API for config loading#111
Merged
cassiofariasmachado merged 5 commits intoMay 12, 2026
Merged
Conversation
Replace the custom mount/env fallback logic in _load_config_from_env with read_from_mount_and_fallback_to_env_var, aligning with the auditlog pattern. BindingData is simplified to two str fields (url, uaa) matching the mount file names. extract_config() now parses the uaa JSON blob to derive token_url, client_id, and client_secret. AgentMemoryConfig.__post_init__ validates all optional fields when provided. Removes _ENV_PREFIX, _ENV_VARS, and _load_binding_from_env which are no longer needed. New env var names: CLOUD_SDK_CFG_HANA_AGENT_MEMORY_DEFAULT_URL CLOUD_SDK_CFG_HANA_AGENT_MEMORY_DEFAULT_UAA
…ver API Rewrite test_config.py to cover the two-field BindingData (url + uaa JSON), the updated extract_config() JSON parsing logic, AgentMemoryConfig field validations, and _load_config_from_env using the public resolver API. Update test_client.py env var names to match the new resolver convention.
Update user-guide.md Configuration section to match the auditlog pattern: service binding summary, directory tree, environment variable examples, and UAA JSON schema. Update INTEGRATION_TESTS.md and .env_integration_tests.example to use the two new env vars (URL and UAA JSON) replacing the four old flat variables.
cassiofariasmachado
approved these changes
May 12, 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.
Description
The
agent_memorymodule previously resolved its service binding credentials using aprivate internal function (
_load_from_mount) and reimplemented the environment variablefallback manually. This PR aligns it with the pattern used by the
auditlogmodule:credentials are now loaded through the public
read_from_mount_and_fallback_to_env_varAPI from the
secret_resolvermodule.What changed:
BindingDatais simplified to twostrfields —urlanduaa— matching themounted secret file names under
/etc/secrets/appfnd/hana-agent-memory/default/.extract_config()now parses theuaaJSON blob to derivetoken_url,client_id,and
client_secret, rather than reading four separate flat fields.AgentMemoryConfig.__post_init__now validates all optional fields (token_url,client_id,client_secret) when provided, rejecting empty strings._ENV_PREFIX,_ENV_VARS, and_load_binding_from_envhelpers are removed.CLOUD_SDK_CFG_HANA_AGENT_MEMORY_DEFAULT_URLCLOUD_SDK_CFG_HANA_AGENT_MEMORY_DEFAULT_UAA(JSON string)Why it matters: Users deploying on BTP with a
hana-agent-memoryservice binding willnow have credentials resolved automatically and consistently with all other SDK modules,
without any changes to their application code.
Type of Change
How to Test
Run the unit test suite for the agent memory module:
Key scenarios covered by the tests:
BindingData.validate()raisesAgentMemoryConfigErrorwhenurloruaais emptyextract_config()correctly parses the UAA JSON and mapsbase_url,token_url,client_id, andclient_secretextract_config()strips trailing slashes from the UAAurlbefore appending/oauth/tokenextract_config()ignores extra fields in the UAA JSON (e.g.apiurl,tenantid)extract_config()raisesAgentMemoryConfigErroron invalid JSON or missing required keys_load_config_from_env()succeeds when the resolver populates the binding_load_config_from_env()falls back toCLOUD_SDK_CFG_HANA_AGENT_MEMORY_DEFAULT_*environment variables when the mount path is unavailable
_load_config_from_env()wraps unexpected resolver failures inAgentMemoryConfigErrorAgentMemoryConfigraisesAgentMemoryConfigErrorfor empty strings on any fieldFor integration tests, set the following in
.env_integration_tests:CLOUD_SDK_CFG_HANA_AGENT_MEMORY_DEFAULT_URL=https://your-agent-memory-api-url CLOUD_SDK_CFG_HANA_AGENT_MEMORY_DEFAULT_UAA='{"url":"https://your-auth-url","clientid":"your-client-id","clientsecret":"your-client-secret"}'Then run:
Checklist
user-guide.md) in the module directoryAdditional Notes
The
uaaJSON schema accepted byextract_config()only requires three fields —url,clientid,clientsecret— and ignores all others. This matches the real BTPservice binding payload, which contains many additional fields (
apiurl,tenantid,zoneid, etc.) that the SDK does not need.