Skip to content

fix(memory): handle SELF_MANAGED override type in _wrap_configuration#290

Open
abhu85 wants to merge 1 commit intoaws:mainfrom
abhu85:fix/memory-self-managed-override-type
Open

fix(memory): handle SELF_MANAGED override type in _wrap_configuration#290
abhu85 wants to merge 1 commit intoaws:mainfrom
abhu85:fix/memory-self-managed-override-type

Conversation

@abhu85
Copy link

@abhu85 abhu85 commented Mar 2, 2026

Summary

Fixes Bug #1 from issue #212: The _wrap_configuration method was crashing with ValueError: 'SELF_MANAGED' is not a valid OverrideType when trying to modify CUSTOM strategies with SELF_MANAGED configuration type.

Root Cause

The code attempted to convert override_type string to OverrideType enum without handling the case where override_type is not a valid enum value (e.g., 'SELF_MANAGED' which is a valid configuration type but not defined in the OverrideType enum).

Changes

  1. Added _try_get_override_type() helper method that safely converts override_type string to OverrideType enum, returning None for invalid/unknown values
  2. Updated _wrap_configuration() to use this helper and fall through to pass-through behavior when override_enum is None or not in the wrapper key dictionaries
  3. Added missing else clauses in the consolidation and reflection handling to ensure configuration is passed through for unknown override types

Tests

Added 3 new tests:

  • test_wrap_configuration_custom_self_managed - verifies SELF_MANAGED configs work without crashing
  • test_try_get_override_type_valid - verifies valid override types are converted correctly
  • test_try_get_override_type_invalid - verifies invalid override types return None

All 110 existing tests continue to pass.

Test Plan

  • All existing _wrap_configuration tests pass (7 tests)
  • All memory client tests pass (110 tests)
  • New tests specifically cover SELF_MANAGED scenario
  • Tests verify extraction, consolidation, and reflection all pass through correctly

Reproduction

Before this fix:

from bedrock_agentcore.memory import MemoryClient
client = MemoryClient(region_name='us-west-2')
client.modify_strategy(
    memory_id='BasicTestMemory2-q8ughRAgdr',
    strategy_id='self_managed_v4ze2-G2RJC0H1bA',
    configuration={
        'extraction': {
            'historicalContextWindowSize': 10,
            'triggerEveryNMessages': 5
        }
    }
)
# Crashes with: ValueError: 'SELF_MANAGED' is not a valid OverrideType

After this fix, the above code works without crashing.

Fixes #212 (Bug #1)


Generated with Claude Code

Bug aws#1 from issue aws#212: The _wrap_configuration method was crashing with
ValueError when trying to modify CUSTOM strategies with SELF_MANAGED
configuration type.

Root cause: The code attempted to convert override_type string to
OverrideType enum without handling the case where override_type is not
a valid enum value (e.g., 'SELF_MANAGED' which is a valid configuration
type but not in the OverrideType enum).

Fix: Add _try_get_override_type() helper method that safely converts
override_type to OverrideType enum, returning None for invalid values.
Update _wrap_configuration to use this helper and fall through to
pass-through behavior when override_enum is None or not in the
wrapper key dictionaries.

This allows CUSTOM strategies with SELF_MANAGED configuration to be
modified without crashing, with their configuration passed through
as-is (no special wrapping).

Fixes aws#212 (Bug aws#1)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@abhu85 abhu85 requested a review from a team March 2, 2026 14:48
@abhu85 abhu85 requested a deployment to manual-approval March 2, 2026 14:49 — with GitHub Actions Waiting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: update_memory_strategies fails when modifying certain strategy types

1 participant