fix(sdk/python/core): raise clear KeeperError for malformed InMemoryKeyValueStorage config (KSM-299)#1057
Open
mgallego-keeper wants to merge 6 commits into
Conversation
…ret and delete_folder
…eyValueStorage config (KSM-299) InMemoryKeyValueStorage given a config string that is not valid JSON (or base64-encoded JSON) raised a cryptic "TypeError: object of type 'NoneType' has no len()". The error path called len() on the json_to_dict() result (None) instead of the source string, and %-formatting evaluated that len() argument before the KeeperError could even be constructed. Preserve the original config string in config_str and report its length, so a malformed config now raises a clear KeeperError explaining the problem. Add regression tests mirroring the existing "must raise KeeperError, not TypeError" pattern in this suite.
Bump python-core from 17.3.0 to 17.4.0 across the three coupled locations (_version.py, the keeper_globals.py hardcoded fallback, and the smoke_test version assertions) and add a 17.4.0 README changelog entry covering KSM-299, KSM-1019, KSM-1080 and KSM-1085.
mgallego-keeper
added a commit
that referenced
this pull request
Jul 9, 2026
…d into 17.4.0) This fix is being consolidated into the 17.4.0 release. The single version bump and the KSM-1019 changelog entry now live in the 17.4.0 release PR (#1057), so revert _version.py, keeper_globals.py, smoke_test.py and the README changelog back to the release-branch baseline. This PR now carries only the KSMCache code fix and its regression tests.
stas-schaller
force-pushed
the
release/sdk/python/core/v17.4.0
branch
from
July 24, 2026 17:38
d541f29 to
c80bdd5
Compare
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.
Summary
InMemoryKeyValueStorageraised a crypticTypeError: object of type 'NoneType' has no len()when constructed with a config string that is not valid JSON or base64-encoded JSON (e.g.InMemoryKeyValueStorage("A")). This fixes KSM-299 so a malformed config produces a clear, actionableKeeperError.Root cause
In
storage.pythe string-config branch reassignsconfigto the result ofjson_to_dict(config)(which isNonefor invalid JSON), then builds the error with... % str(len(config)). Python evaluates thelen(config)operand before constructing theKeeperError, solen(None)raisesTypeErrorfirst — the intended "Could not load config data" message never surfaces.Fix
config_strand report its length, so the error path no longer callslen()on the parsed (possiblyNone) result.Could not load config data. The configuration string is not valid JSON or base64-encoded JSON (text length: N).Tests
Added two regression tests to
config_error_test.py, following the existing "must raiseKeeperError, notTypeError" pattern:"A") — the exact ticket reproVerified locally: full
config_error_test.pypasses (17 tests) and the version smoke test passes.Release / version
17.3.0 → 17.4.0across the three coupled locations (_version.py, thekeeper_globals.pyhardcoded fallback, and thesmoke_test.pyassertions).### 17.4.0README changelog covering KSM-299 and the other fixes staged on this release branch (KSM-1019, KSM-1080, KSM-1085).Notes for reviewers
release/sdk/python/core/v17.4.0already has the latestmastermerged in (keeper_secrets_manager_storagesv1.1.0).