Skip to content

Validate user actions before applying anything - #318

Open
TeunHuijben wants to merge 2 commits into
mainfrom
validate_before_apply
Open

TeunHuijben wants to merge 2 commits into
mainfrom
validate_before_apply

Conversation

@TeunHuijben

Copy link
Copy Markdown
Collaborator

This is something we need in order to have a consistent change/history log in nTE. A re-applyable history log only works when every recorded action was as it did, and every change is reported in the changelog. Which is currently not the case, because some (User)Actions make changes to the graph, and later hit an error before addin things to the undo/redo history and thereby history log.

So the two things this PR ensures:

  1. what happens can be reproduced (right now, not every action is undoable, when a error is raised after changes are applied)
  2. a failed action change nothing:

🤖:

Some user actions could fail halfway: they changed the graph, then raised, and nothing went into the undo history, so the change could not be undone.

  • User actions now run every check before their first change (UserAddEdge, UserDeleteEdge, UserAddNode, UserSetDivision, UserDeleteNodes, UserUpdateNodesAttrs, UserUpdateSegmentation).
  • Safety net: if a user action raises anyway, ActionGroup undoes the steps it already applied.
  • AddNode.validate_attributes is shared by AddNode and UserAddNode.
  • UserAddNode no longer changes the caller's attributes dict.

Behaviour changes:

  • UserDeleteNodes ignores duplicate ids.
  • UserUpdateNodesAttrs raises InvalidActionError for unknown nodes.
  • UserUpdateSegmentation raises InvalidActionError when the painted-over node is not in the solution.

Known issue, not fixed here: undoing a merge restores the pixels but leaves the mask's bounding box too large (marked xfail).

@codecov

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.63014% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 94.45%. Comparing base (b6b76ca) to head (a5a1c95).

Files with missing lines Patch % Lines
src/funtracks/actions/_base.py 94.44% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #318      +/-   ##
==========================================
+ Coverage   94.36%   94.45%   +0.09%     
==========================================
  Files          64       64              
  Lines        3883     3929      +46     
==========================================
+ Hits         3664     3711      +47     
+ Misses        219      218       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
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