You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Native build: saving a find_nearest(include_vector=True) hit fails with 'Object of type RID is not JSON serializable' #265
On main (a53f9cd6cc), the native build fails to save a record that find_nearest(..., include_vector=True) returned. Found by the parity leg of #264 (linux-x86_64, Python 3.12), in a test that passed on each PR of the batch on its own:
FAILED tests/test_vector_hit_records.py::test_a_hit_can_be_modified_and_saved[True] - TypeError: Object of type RID is not JSON serializable
records.py:371 _save_update: db.query("sql", self._SELECT, {"rid": RID(self._rid)})
codec.py:217 encode_params: text = _dumps({"named": out})
Cause: a hit of find_nearest(include_vector=True) carries the row's RID as its rid, and the native record wrappers wrap their rid again (RID(self._rid) in save, the update, delete, new_edge and the edge reads). RID.__init__ stores its argument as is, so the result is an RID whose .text is an RID. The fast named-parameter path of codec.encode_params writes {TAG: ["R", v.text]} straight into the JSON text, and json cannot encode the inner RID. Reproduced without the engine:
encode_params([{"rid": RID("#1:2")}], binary=True) # okencode_params([{"rid": RID(RID("#1:2"))}], binary=True) # TypeError: Object of type RID is not JSON serializable
The slower paths (a named map with a non-plain value, positional parameters) go through the default hook, which calls itself for the inner RID and sends a nested tag instead of failing.
Affected: the native wheel (arcadedb) only, every write or edge call on a record whose rid is an RID object (a hit with include_vector=True is the one found). The JVM wheel is not affected. This blocks the 26.11.1 tag (#18): the release must not ship it.
Activity