Skip to content

[Bug] Revert doesn't clear unapplied logs — saving after revert replays reverted transformations #49

@Premkumar-2004

Description

@Premkumar-2004

Describe the bug
Reverting a dataset doesn't clear the unapplied logs from the database. So if you revert and then save, all the old transformations get replayed on the original CSV again — basically undoing your revert.

To Reproduce
Steps to reproduce the behavior:

  1. Upload a CSV and open the dataset
  2. Add a row
  3. Go to File → View Checkpoints → click Revert
  4. Table goes back to original
  5. Now go to File → Save Dataset, type any commit message
  6. The row you reverted is back. The save replayed it.

Expected behavior
After reverting, saving should have nothing to apply. The reverted changes shouldn't come back.

The revert endpoint (POST /{dataset_id}/revert in datasets.py) copies the original CSV back to the working copy, but it doesn't touch the user_logs table. The log entries from before the revert are still sitting there with applied = False.
Then when you hit save, save_dataset does this:

logs = db.query(models.DatasetChangeLog).filter( models.DatasetChangeLog.dataset_id == dataset_id, models.DatasetChangeLog.applied == False ).order_by(models.DatasetChangeLog.timestamp).all()

The fix is just deleting the unapplied logs during revert, before the commit:

db.query(models.DatasetChangeLog).filter( models.DatasetChangeLog.dataset_id == dataset_id, models.DatasetChangeLog.applied == False ).delete()

Environment:

  • OS: macOS
  • Browser: Chrome
  • Python: 3.13

Additional context
Any other relevant information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions