Skip to content

Commit d2cf53c

Browse files
jac0626silas.jiang
andauthored
fix: Keep boolean serialization as uppercase for e2e compatibility (#3167)
- Keep boolean serialization as uppercase for e2e compatibility - Updated unit tests to expect uppercase boolean values Signed-off-by: silas.jiang <silas.jiang@zilliz.com> Co-authored-by: silas.jiang <silas.jiang@zilliz.com>
1 parent 20c43b4 commit d2cf53c

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
@@ -316,10 +316,9 @@ def get_server_type(host: str):
316316

317317

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

tests/test_prepare.py

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

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

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

0 commit comments

Comments
 (0)