From 2a0cd50a14b528cf786a884a9f8498ecbf947296 Mon Sep 17 00:00:00 2001 From: yfsn666 Date: Sun, 28 Sep 2025 09:33:33 +0800 Subject: [PATCH] [INLONG-12010][SDK] Fix the problem of truncated string data containing Chinese characters when reporting using Dataproxy Python SDK --- .../dataproxy-sdk-python/inlong_dataproxy.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-python/inlong_dataproxy.cpp b/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-python/inlong_dataproxy.cpp index 4c2972ff19b..257fb409580 100644 --- a/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-python/inlong_dataproxy.cpp +++ b/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-python/inlong_dataproxy.cpp @@ -65,13 +65,16 @@ PYBIND11_MODULE(inlong_dataproxy, m) { return result; }) .def("send", [](inlong::InLongApi& self, const char* groupId, const char* streamId, const char* msg, int32_t msgLen, py::object pyCallback = py::none()) { + // Recalculate the message length by C++ rules + int32_t sendLen = static_cast(strlen(msg)); + if (!pyCallback.is(py::none())) { g_py_callbacks[UserCallBackBridge] = pyCallback.cast(); py::gil_scoped_release release; - int result = self.Send(groupId, streamId, msg, msgLen, UserCallBackBridge); + int result = self.Send(groupId, streamId, msg, sendLen, UserCallBackBridge); return result; } else { - int result = self.Send(groupId, streamId, msg, msgLen, nullptr); + int result = self.Send(groupId, streamId, msg, sendLen, nullptr); return result; } })