fix: preserve http_auth in _safe_deepcopy_config for OpenSearch (#3580)#4418
Merged
kartik-mem0 merged 1 commit intomainfrom Mar 19, 2026
Merged
fix: preserve http_auth in _safe_deepcopy_config for OpenSearch (#3580)#4418kartik-mem0 merged 1 commit intomainfrom
kartik-mem0 merged 1 commit intomainfrom
Conversation
Replace broad substring sanitizer with layered allow/deny field matching to prevent runtime auth objects (http_auth, connection_class) from being nullified during telemetry config cloning. Also fix model_dump(mode="json") to model_dump() to preserve actual Python objects instead of relying on a PydanticSerializationError fallback. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
kartik-mem0
approved these changes
Mar 19, 2026
Contributor
kartik-mem0
left a comment
There was a problem hiding this comment.
all of the changes lgtm!
This was referenced Mar 19, 2026
This was referenced Mar 19, 2026
jamebobob
pushed a commit
to jamebobob/mem0-vigil-recall
that referenced
this pull request
Mar 29, 2026
…ai#3580) (mem0ai#4418) Co-authored-by: utkarsh240799 <utkarsh240799@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
_safe_deepcopy_config()used broad substring matching to sanitize sensitive fields during telemetry config cloning. The token"auth"matchedhttp_auth, and"connection_class"was listed explicitly — both are runtime objects required by OpenSearch's AWS SigV4 authentication (AWSV4SignerAuth,RequestsHttpConnection). Whendeepcopyfails for these non-serializable objects, the fallback path nullified them, causingAuthorizationException(403, '')errors.Root cause
Fix
Replaced the broad substring sanitizer with a 3-layer field matching system:
_RUNTIME_FIELDS) — runtime objects likehttp_auth,auth,connection_class,ssl_contextare always preserved (highest priority)_SENSITIVE_FIELDS_EXACT) — 19 known secret field names (api_key,password,secret_key,auth_client_secret, etc.)_SENSITIVE_SUFFIXES) — catches patterns likedb_password,client_secret,oauth_tokenAlso fixed
model_dump(mode="json")→model_dump()to preserve actual Python objects instead of relying on aPydanticSerializationErrorfallback to the__dict__path.Removed a dead
_safe_deepcopy_configcall in the syncMemory.__init__whose result was immediately overwritten.Fixes #3580
Type of change
How Has This Been Tested?
Unit tests (106 total, all passing)
New test file
tests/memory/test_safe_deepcopy_config.py— 94 tests covering:_is_sensitive_field()allowlist, exact deny, suffix deny, case insensitivity, edge casesprimary_key,partition_key,monkey,keyboard,tokenizer,authenticate,credentials_pathare correctly NOT redacted_safe_deepcopy_config()integration with plain classes, Pydantic BaseModel, and dataclassesresult.http_auth is auth(actual object identity preserved)Updated
tests/vector_stores/test_opensearch.py— flipped assertions fromis Nonetois not Noneforhttp_auth,auth,connection_classwhile keepingcredentials is NoneManual verification
Reproduced the exact scenario from #3580 using real
OpenSearchConfigwith mockAWSV4SignerAuth(thread lock, raises on__deepcopy__). Verified both sync and async telemetry flows preserve auth objects end-to-end.Checklist:
Maintainer Checklist