Skip to content

Commit 6f891fc

Browse files
pymilvus-botjac0626silas.jiang
authored
[Backport 2.6] fix: Keep boolean serialization as uppercase for e2e compatibility (#3167) (#3168)
Backport of #3167 to `2.6`. Signed-off-by: silas.jiang <silas.jiang@zilliz.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: jac <jacllovey@qq.com> Co-authored-by: silas.jiang <silas.jiang@zilliz.com>
1 parent 1f880dc commit 6f891fc

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

pymilvus/client/utils.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,9 @@ def get_server_type(host: str):
315315

316316

317317
def dumps(v: Union[dict, str]) -> str:
318-
# Use JSON serialization for dicts and booleans to ensure consistent formatting
319-
# (e.g., booleans are serialized as 'true'/'false' not 'True'/'False')
320-
# For other types (strings, numbers), use str() to maintain compatibility
321-
if isinstance(v, (dict, bool)):
318+
# Use JSON serialization for dicts to ensure proper formatting
319+
# For other types (strings, numbers, booleans), use str() to maintain compatibility
320+
if isinstance(v, dict):
322321
return orjson.dumps(v).decode(Config.EncodeProtocol)
323322
return str(v)
324323

tests/test_prepare.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,8 @@ def test_create_index_request_with_false_boolean_param(self):
554554
param_values = {p.key: p.value for p in req.extra_params}
555555

556556
assert "with_raw_data" in param_keys, "with_raw_data parameter should be included"
557-
assert param_values["with_raw_data"] == "false", "with_raw_data should be serialized as 'false'"
557+
# Short-term fix: booleans are serialized as uppercase "False"/"True" for e2e compatibility
558+
assert param_values["with_raw_data"] == "False", "with_raw_data should be serialized as 'False'"
558559
assert "index_type" in param_keys
559560
# String values are serialized as plain strings (without quotes) for compatibility
560561
assert param_values["index_type"] == "SCANN", "index_type should be serialized as plain string"
@@ -576,7 +577,8 @@ def test_create_index_request_with_true_boolean_param(self):
576577
param_values = {p.key: p.value for p in req.extra_params}
577578

578579
assert "with_raw_data" in param_keys, "with_raw_data parameter should be included"
579-
assert param_values["with_raw_data"] == "true", "with_raw_data should be serialized as 'true'"
580+
# Short-term fix: booleans are serialized as uppercase "False"/"True" for e2e compatibility
581+
assert param_values["with_raw_data"] == "True", "with_raw_data should be serialized as 'True'"
580582
assert param_values["index_type"] == "SCANN", "index_type should be serialized as plain string"
581583
assert param_values["metric_type"] == "L2", "metric_type should be serialized as plain string"
582584

0 commit comments

Comments
 (0)