Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/main/conversions.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
16 changes: 16 additions & 0 deletions test/new_tests/test_invalid_map_keys.py
Original file line number Diff line number Diff line change
@@ -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})
Loading