[SYNPY-1863] deepcopy annotations in SubmissionStatus._set_last_persistent_instance#1414
Merged
Merged
Conversation
BryanFauble
reviewed
Jun 26, 2026
BryanFauble
requested changes
Jun 26, 2026
BryanFauble
left a comment
Member
There was a problem hiding this comment.
Can we get away with a unit test only for this change to verify the has_changed and this _set_last_persistent_instance logic?
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes change-tracking on SubmissionStatus so in-place mutations to mutable annotation fields (e.g., dict.update()) are detected and persisted, avoiding “object has not been modified” warnings and missed updates.
Changes:
- Deep-copies
annotationsandsubmission_annotationswhen stashing_last_persistent_instanceto prevent shared references. - Adds async integration tests covering in-place mutation scenarios for both annotation containers.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
synapseclient/models/submission_status.py |
Adjusts last-persistent snapshotting to avoid shared references for mutable annotation fields. |
tests/integration/synapseclient/models/async/test_submission_status_async.py |
Adds integration tests asserting in-place dict mutations are detected and stored. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
andrewelamb
reviewed
Jun 26, 2026
BryanFauble
approved these changes
Jun 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem:
When calling
<SubmissionStatusObject>.submission_annotations.update()on aSubmissionStatusobject, the dataclass does not register a change and throws a warning that the object has not been modified, resulting in the annotations never being correctly posted to Synapse.Solution:
Implement the pattern already established in the repository (example: Project OOP model) by performing
deepcopyon mutable objects, such as dicts, while performingreplace(shallow copy) on immutable objects where it doesn't matter if the 2 instances (last and current) share references.This should prevent issues with the client not detecting changes to the dataclass instance when a user performs in-place mutations instead of re-assigning the attribute, i.e:
Testing:
✅ Can no longer reproduce user-error
New tests that cover in-place mutation scenarios are passing: