Skip to content

fix(seg layer): Save anchor segment in JSON state as string not BigInt if defined#916

Open
seankmartin wants to merge 3 commits intogoogle:masterfrom
MetaCell:fix/anchor-segment-serialize
Open

fix(seg layer): Save anchor segment in JSON state as string not BigInt if defined#916
seankmartin wants to merge 3 commits intogoogle:masterfrom
MetaCell:fix/anchor-segment-serialize

Conversation

@seankmartin
Copy link
Contributor

@seankmartin seankmartin commented Mar 23, 2026

Fixes #897

The issue was that the anchorSegment ID in segmentation layers was being saved into the JSON state directly as a big int if it was defined, instead of being saved as a string like other segmentation IDs. This changes the anchorSegment to be saved as string if defined.

This bug did not affect all of the application, as many parts of the application use a bigintToStringJsonReplacer when calling JSON.stringify on the JSON state. However, the state editor does not use this replacer pattern nor does the screenshot actions in src/python_integration/screenshot.ts. I have added the bigintToStringJsonReplacer call to the screenshot action to be on the safe side there. But I'm unsure if it should be added to the JSON state editor. Adding this protection to the editor could possibly help hide a case where a big int value is incorrectly stored in the state and potentially incorrectly parsed from the state.

Copy link
Contributor

@chrisj chrisj left a comment

Choose a reason for hiding this comment

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

I could go either way for adding the protection but since adding it would reduce the chance of a user error, it seems like the right choice.

@seankmartin
Copy link
Contributor Author

I could go either way for adding the protection but since adding it would reduce the chance of a user error, it seems like the right choice.

Cheers Chris, added it in so!

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.

Layers with equivalence info fail to serialize to JSON due to BigInt serializing failure

2 participants