Skip to content

Item version saving pollutes item_version with lots of null values #2020

Description

@be-smith

This bug has been hard to replicate.

When a block is made then a manual save triggered the block data can show up in the diff:

Image

Steps to reproduce:

  1. Make a new sample
  2. Change something trivial and save by clicking the floppy disk
  3. Add a block (preferably CycleBlock)
  4. Attach a file
  5. Click Save Item again
  6. View Version History

The fix is in items.py on line 1798 for save_item to change:

item = ITEM_MODELS[item_type](**item).dict()

to

item = ITEM_MODELS[item_type](**item).dict(exclude_none=True)

But worth checking follow on effects of this change:

"Fixed" behaviour:

Image

I believe this behaviour is already fixed in pydantic v2 due to exclude_unset=True being used there

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions