Skip to content

Comments

[Backport 2.6] fix: use deepcopy for struct_schema in add_field to prevent reuse issues (#3105)#3123

Merged
sre-ci-robot merged 1 commit into2.6from
backport-3105-to-2.6-1764737037-1273
Dec 3, 2025
Merged

[Backport 2.6] fix: use deepcopy for struct_schema in add_field to prevent reuse issues (#3105)#3123
sre-ci-robot merged 1 commit into2.6from
backport-3105-to-2.6-1764737037-1273

Conversation

@pymilvus-bot
Copy link
Collaborator

Manual backport of #3105 to 2.6.

…ues (#3105)

## Summary
- Fix struct_schema reuse bug in `CollectionSchema.add_field()` method
- When reusing the same `struct_schema` object across multiple
`ARRAY<STRUCT>` fields, the method was directly modifying the original
object, causing "duplicated field name" errors
- Wrap `struct_schema` with `copy.deepcopy()` to ensure each field gets
an independent copy, consistent with how the constructor handles
struct_fields

Fixes #3104

## Test plan
- [x] Verified fix with test script that reuses struct_schema for
multiple fields
- [x] All existing schema tests pass (11/11)
- [x] Code passes linting (black + ruff)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: zhuwenxing <[email protected]>
Co-authored-by: Claude <[email protected]>
(cherry picked from commit 7130008)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Copy link
Contributor

@XuanYang-cn XuanYang-cn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@sre-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pymilvus-bot, XuanYang-cn

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

The pull request process is described 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 sre-ci-robot merged commit 8993416 into 2.6 Dec 3, 2025
11 checks passed
@XuanYang-cn XuanYang-cn deleted the backport-3105-to-2.6-1764737037-1273 branch December 3, 2025 06:33
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.

5 participants