Skip to content

fix(graph): avoid mutating append inputs#4780

Open
Gujiassh wants to merge 1 commit into
alibaba:mainfrom
Gujiassh:fix/append-strategy-immutability-4757
Open

fix(graph): avoid mutating append inputs#4780
Gujiassh wants to merge 1 commit into
alibaba:mainfrom
Gujiassh:fix/append-strategy-immutability-4757

Conversation

@Gujiassh

@Gujiassh Gujiassh commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Describe what this PR does / why we need it

This keeps AppendStrategy.apply(oldValue, newValue) side-effect free when oldValue is already a List and newValue is a single non-collection value.

Today that branch appends directly into the incoming oldList and returns the same instance. Any caller that still holds the original list reference can observe the mutation, which leaks state across history snapshots and checkpointed branches.

Does this pull request fix one issue?

Fixes #4757

Describe how you did it

  • change the single-value append branch to copy oldList into a new ArrayList
  • append the new value to the copied list instead of mutating the original reference
  • add a focused regression test that proves oldList stays unchanged while the returned list contains the appended value

Describe how to verify it

  • ./mvnw -pl spring-ai-alibaba-graph-core -Dtest=AppendStrategyMutationRegressionTest test
  • git diff --check

Special notes for reviews

This is intentionally scoped to the single-value append path only. Existing list/list merge behavior and remove-identifier handling are left unchanged.

@github-actions github-actions Bot added the area/graph SAA Grpah module label Jul 6, 2026
@Gujiassh Gujiassh force-pushed the fix/append-strategy-immutability-4757 branch from 3e59352 to 46be2ee Compare July 10, 2026 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/graph SAA Grpah module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] AppendStrategy.apply() 单值追加分支原地修改 oldValue,导致历史快照 / checkpoint 状态污染

1 participant