From 15be1dd390b074d80569dd076cbf154dbb6365e8 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 13 Apr 2026 16:00:21 -0700 Subject: [PATCH 1/2] Check if c client layer fails when converting python dict to c client as_map --- src/main/conversions.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/conversions.c b/src/main/conversions.c index 6576252d5c..f63955562c 100644 --- a/src/main/conversions.c +++ b/src/main/conversions.c @@ -725,7 +725,14 @@ as_status pyobject_to_map(AerospikeClient *self, as_error *err, } break; } - as_map_set(*map, key, val); + int retval = as_map_set(*map, key, val); + if (retval != 0) { + // TODO: message not specific enough + as_error_update( + err, AEROSPIKE_ERR_CLIENT, + "Failed to convert Python dictionary to a C client as_map."); + break; + } } if (err->code != AEROSPIKE_OK) { From 0ca32cbe7032ac3905425e9b30a19026fa9acb64 Mon Sep 17 00:00:00 2001 From: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com> Date: Mon, 13 Apr 2026 17:26:10 -0700 Subject: [PATCH 2/2] Add test case --- test/new_tests/test_invalid_map_keys.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 test/new_tests/test_invalid_map_keys.py diff --git a/test/new_tests/test_invalid_map_keys.py b/test/new_tests/test_invalid_map_keys.py new file mode 100644 index 0000000000..6b21a09c0e --- /dev/null +++ b/test/new_tests/test_invalid_map_keys.py @@ -0,0 +1,16 @@ +import pytest +from .conftest import KEYS +from aerospike import exception as e + + +@pytest.mark.usefixtures("as_connection") +class TestInvalidMapKeys: + def test_passing_invalid_map_keys_raises_exc(self): + KEY = KEYS[0] + invalid_map_in_server = { + 4.0: 1 + } + # TODO: should raise ParamError + # Python client can check if valid key, since C client doesn't raise a specific enough error in as_map_set + with pytest.raises(e.ClientError): + self.as_connection.put(KEY, bins={"map": invalid_map_in_server})