Skip to content

Python core: KSMCache ignores kms_cache_file_name override after KSM-1004 #1044

Description

@Wade-0

Bug Summary

After PR #1034 (KSM-1004: resolve KSMCache path lazily so KSM_CACHE_DIR is honored after import), KSMCache.kms_cache_file_name is no longer used by cache operations.

This appears to be a breaking change for consumers that override KSMCache.kms_cache_file_name programmatically instead of using KSM_CACHE_DIR.

Current Behavior

save_cache, get_cached_data, and remove_cache_file now call KSMCache.get_cache_file_path(), which always resolves the path from KSM_CACHE_DIR and the default filename:

os.path.join(os.environ.get("KSM_CACHE_DIR", ""), "ksm_cache.bin")

As a result, changing:

KSMCache.kms_cache_file_name = "/custom/path/my_cache.bin"

has no effect.

Expected Behavior

If kms_cache_file_name is kept for backward compatibility, cache operations should still honor it.

At minimum, one of these should be true:

  1. kms_cache_file_name continues to override the cache file path when explicitly set, or
  2. the attribute is removed or deprecated clearly as a breaking change and documented accordingly.

Why this is a problem

The PR description says:

Keep the kms_cache_file_name class attribute for backward compatibility (no longer governs behavior)

But if existing integrations depended on setting that attribute, behavior has changed incompatibly.

Reproduction

Before PR #1034, code like this worked:

from keeper_secrets_manager_core.core import KSMCache

KSMCache.kms_cache_file_name = "/tmp/custom_cache.bin"
KSMCache.save_cache(b"test")
assert KSMCache.get_cached_data() == b"test"
KSMCache.remove_cache_file()

After PR #1034, the override is ignored and the cache is written to the path derived from KSM_CACHE_DIR or the default CWD-relative location instead.

Suggested Fix

Consider updating get_cache_file_path() to preserve the legacy override behavior, for example by honoring kms_cache_file_name when it has been explicitly changed from the default value.

Alternatively, document this as a breaking change and provide a supported migration path.

Related

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions