Skip to content

fix mutable default argument in StateItem metadata - #1219

Open
magic-peach wants to merge 1 commit into
dapr:mainfrom
magic-peach:fix/state-item-mutable-default-metadata
Open

magic-peach wants to merge 1 commit into
dapr:mainfrom
magic-peach:fix/state-item-mutable-default-metadata

Conversation

@magic-peach

Copy link
Copy Markdown
Contributor

Description

StateItem.__init__ had metadata: Optional[Dict[str, str]] = dict(), a mutable default argument. The same dict object is reused across every StateItem created without an explicit metadata, so mutating one instance's metadata in place leaks into every other instance. Fixed with the standard None default plus an empty dict built per instance.

Issue reference

We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: N/A, self-discovered while reviewing this file, no existing issue filed.

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

Signed-off-by: Akanksha Trehun <akankshatrehun@gmail.com>
@magic-peach
magic-peach requested review from a team as code owners September 18, 2026 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant