Skip to content

fix: join batch insert/upsert size-mismatch error message into a string - #3956

Closed
AyusK4 wants to merge 1 commit into
milvus-io:masterfrom
AyusK4:fix/batch-request-tuple-message
Closed

AyusK4 wants to merge 1 commit into
milvus-io:masterfrom
AyusK4:fix/batch-request-tuple-message

Conversation

@AyusK4

@AyusK4 AyusK4 commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #3843.

Prepare._parse_batch_request (used by batch_insert_param and batch_upsert_param) raised a ParamError whose message was built from three f-strings separated by commas:

raise ParamError(
    message=(
        f"Field data size misaligned for field [{entity.get('name')}] ",
        f"got size=[{latest_field_size}] ",
        f"alignment size=[{pre_field_size}]",
    )
)

Because of the commas, this is a 3-tuple literal, not implicit string concatenation, so message ended up a tuple instead of a str:

ParamError: (code=1, message=('Field data size misaligned for field [b] ', 'got size=[2] ', 'alignment size=[3]'))

Removed the commas so the adjacent f-strings concatenate into a single string:

ParamError: (code=1, message=Field data size misaligned for field [vector] got size=[2] alignment size=[3])

The existing test for this path (test_field_size_mismatch) only asserted pytest.raises(ParamError, match="misaligned"), which matches against str(exception) and passed even with the tuple bug — that's why it went unnoticed. Strengthened it to assert message is a str with the exact expected text, so this can't silently regress.

Validation

  • pytest tests/unit/prepare/test_data.py -v -k field_size_mismatch: passes with the new string-equality assertion.
  • pytest tests/unit -q: 5987 passed, 2 skipped, 4 failed — the 4 failures are pre-existing and unrelated (Windows symlink-permission tests in test_volume_upload_policy.py and a git-metadata check in test_check.py), reproducible on master before this change.
  • black pymilvus tests --check --diff and ruff check pymilvus tests: both clean on the changed files.

_parse_batch_request built the ParamError message from three f-strings
separated by commas, making message a 3-tuple instead of a string.
Join them with implicit string concatenation (no commas) so the
rendered error is readable text instead of a tuple repr.

Fixes milvus-io#3843

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Ayush <ayushkc078@gmail.com>
@sre-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: AyusK4
To complete the pull request process, please assign czs007 after the PR has been reviewed.
You can assign the PR to them by writing /assign @czs007 in a comment when ready.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sre-ci-robot

Copy link
Copy Markdown

Welcome @AyusK4! It looks like this is your first PR to milvus-io/pymilvus 🎉

@mergify

mergify Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

This pull request is closed, so it cannot be queued. Reopen it to get the box back.

@AyusK4 AyusK4 closed this Nov 27, 2026
@AyusK4
AyusK4 deleted the fix/batch-request-tuple-message branch November 27, 2026 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Mismatched column sizes in batch insert/upsert raise a ParamError whose message is a tuple

2 participants