Skip to content

Conversation

@DomPeliniAerospike
Copy link
Collaborator

@DomPeliniAerospike DomPeliniAerospike commented Jan 8, 2024

This approach does not change the helper function get_cdt_ctx() which currently only accepts an optional Python dictionary. We're avoiding changes to get_cdt_ctx() since it is used in many places in cdt_list_operate.c and cdt_map_operate.c. In the future we will refactor cdt_{list,map}_operate.c to make it easier to refactor these type of helper functions

Extra changes:

  • CLIENT-3652 Fix query.where() not accepting None as ctx argument
  • Fix bug where index_cdt_create() raises a blank AerospikeError exception when receiving an invalid ctx parameter
  • Remove unused raise_exception_old() declaration
  • Fixed TestBaseClass.major_ver and TestBaseClass.minor_ver not being initialized for test files that use TestBaseClass.get_new_connection() and not the as_connection fixture to initialize the Python client

Known issues

  • There's some missing code coverage in index_cdt_create() because ctx is a required parameter (non-NULL) and will always be passed to get_cdt_ctx in a Python dictionary. So when get_cdt_ctx succeeds, ctx_in_use will always be true.

Manual testing

  • Code coverage looks ok
  • Valgrind shows no memory leaks or errors related to these changes
  • Build artifacts passes
  • Massif memory usage looks ok
  • Repro script passes with this PR. See jira ticket

CLIENT-2383
Added support for context lists in Client.index_cdt_create() and Client.Query.where()
Fixed the check for TestBaseClass.version not working corerctly upon initialization
@codecov-commenter
Copy link

codecov-commenter commented Jan 8, 2024

Codecov Report

❌ Patch coverage is 70.96774% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.31%. Comparing base (b658400) to head (ffdbd22).
⚠️ Report is 3 commits behind head on dev.

Files with missing lines Patch % Lines
src/main/client/sec_index.c 61.53% 5 Missing ⚠️
src/main/query/where.c 77.77% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #550      +/-   ##
==========================================
+ Coverage   83.30%   83.31%   +0.01%     
==========================================
  Files          99       99              
  Lines       14402    14422      +20     
==========================================
+ Hits        11997    12016      +19     
- Misses       2405     2406       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@juliannguyen4 juliannguyen4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

query.where() is missing a test case.

PyObject *op_dict, bool *ctx_in_use,
as_static_pool *static_pool, int serializer_type)
{
PyObject *py_ctx = PyDict_GetItemString(op_dict, CTX_KEY);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be better to modify Client.index_cdt_create() and Query.where() directly, instead of this helper function. Many other functions use this helper function, so this change might introduce a bug somewhere else in the client.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. I added these changes in the newest commit

Added Documentation
Added test cases for ctx dictionary legacy support
Ran precommit lint
@DomPeliniAerospike DomPeliniAerospike changed the title CLIENT-2383 CLIENT-2383 - Context arguments must accept a context list Feb 5, 2024
@DomPeliniAerospike DomPeliniAerospike changed the base branch from stage to dev November 14, 2025 14:12
DomPeliniAerospike and others added 14 commits November 14, 2025 07:26
Fixed memory leak in get_cdt_ctx
Fixed misuse of Py_Decref
* [CLIENT-3793] Remove macOS 13 support (#846)

* Auto-bump version to 18.1.0rc3.dev1 [skip ci]

* [CLIENT-3106] Remove dead code in conversions.c (#817)

- record_to_resultpyobject() was a helper function for client.batch_get_ops(), which is now removed.
- record_to_pyobject_cnvt_list_to_map() and as_list_of_map_to_py_tuple_list(): these were helper functions that were used before Python client version 2.1.3 to return the result of certain map operations. They are no longer used starting from Python client 2.1.3 and higher, so it is safe to remove
- bin_strict_type_checking() isn't used anywhere. But it would be good to consolidate the bin checking code into one place, since it is currently spread out all over the codebase
- as_batch_read_results_to_pyobject() was used by get_many() which has been removed
- batch_read_records_to_pyobject() was used by select_many() which has been removed

Extra Changes

Merge do_*_to_pyobject() methods into their calling methods, since they have the same function signature

* Auto-bump version to 18.1.0rc3.dev2 [skip ci]

---------

Co-authored-by: Julian Nguyen <109386615+juliannguyen4@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@juliannguyen4 juliannguyen4 changed the title CLIENT-2383 - Context arguments must accept a context list CLIENT-2383 - Fix bug where Query.where(), client.index_cdt_create() and other operations do not accept a list of contexts Jan 2, 2026
@juliannguyen4 juliannguyen4 changed the title CLIENT-2383 - Fix bug where Query.where(), client.index_cdt_create() and other operations do not accept a list of contexts CLIENT-2383 - Fix bug where Query.where() and client.index_cdt_create() do not accept a list of contexts Jan 2, 2026
@juliannguyen4 juliannguyen4 removed their request for review January 13, 2026 23:09
@juliannguyen4 juliannguyen4 changed the title [CLIENT-2383] Fix bug where Query.where() and client.index_cdt_create() do not accept a list of contexts [CLIENT-2383] Fix bug where Query.where() and client.index_cdt_create() do not accept a list of contexts or None Jan 14, 2026
@juliannguyen4 juliannguyen4 changed the title [CLIENT-2383] Fix bug where Query.where() and client.index_cdt_create() do not accept a list of contexts or None [CLIENT-2383] Fix bug where Query.where() and client.index_cdt_create() do not accept a list of contexts Jan 14, 2026
Copy link
Contributor

@justinlee-aerospike justinlee-aerospike left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks fine. Can you please add negative tests around parse errors in context?

@juliannguyen4
Copy link
Collaborator

juliannguyen4 commented Jan 15, 2026

Both query.where and client.index_cdt_create() have test cases where an invalid type object is passed to the ctx parameter

test_neg_cdtindex_with_invalid_ctx -- None and a non-list object are both rejected since index_cdt_create's ctx parameter is required
test_query_with_invalid_list_cdt_ctx_dict -- None is acceptable for query.where()'s ctx parameter because it is optional. There's currently enough test cases that pass in a valid ctx or omit passing anything to the ctx parameter in query.where()

@juliannguyen4
Copy link
Collaborator

Bump

Copy link
Contributor

@justinlee-aerospike justinlee-aerospike left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes look good

@juliannguyen4 juliannguyen4 dismissed their stale review January 16, 2026 17:41

Justin already approved and I worked on the requested changes

@juliannguyen4 juliannguyen4 merged commit 2d5c83f into dev Jan 16, 2026
186 of 187 checks passed
@juliannguyen4 juliannguyen4 deleted the CLIENT-2383 branch January 16, 2026 17:44
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.

5 participants