Skip to content

fix: reject workflow saves from a stale draft - #638

Merged
Sev7eNup merged 1 commit into
mainfrom
fix/stale-workflow-save-conflict
Oct 24, 2026
Merged

Sev7eNup merged 1 commit into
mainfrom
fix/stale-workflow-save-conflict

Conversation

@Sev7eNup

Copy link
Copy Markdown
Owner

Fixes #609

Two tabs that loaded the same version could both save, and the second save silently replaced the first one's changes. Update and publish now carry expectedVersion; the server answers 409 workflow_version_conflict when it does not match the stored version, before anything is written.

  • API: expectedVersion is required on PUT /api/workflows/{id} and POST /{id}/publish. The check runs after the lock check, and the existing compare-and-swap already matches on the loaded version, so it is atomic.
  • Designer: sends the version it synced and advances it after each save/publish. On a conflict the draft is kept, a message explains it, and autosave stops until reload.
  • CLI, MCP, the load-test client and the admin/test-suite scripts send the version they read.
  • Docs (API reference DE/EN, MCP-relevant notes, CLAUDE.md edit lifecycle) updated.

This is a breaking change for external callers of the two endpoints: a body without expectedVersion is now rejected with 400.

Tests run locally:

  • NodePilot.Api.Tests (WorkflowsEditLockTests, WorkflowsControllerTests, WorkflowPortabilityTests): 93 passed, including the two-tab regression
  • NodePilot.Cli.Tests (NodePilotApiClientTests, ApiDtoParityTests, CommandIntegrationTests): 123 passed
  • NodePilot.Mcp.Tests WorkflowEditToolsTests 7, DocumentationCountsTests 29
  • NodePilot.Engine.Tests LoadHarnessContractTests 8
  • vitest: useWorkflowPersistence, WorkflowEditorPage, demo (287), docs-ui (227)
  • scripts/test_nodepilot_admin_scripts.py (14) and Test-WorkflowCatalogue.ps1
  • full solution build

🤖 Generated with Claude Code

Update and publish now require expectedVersion, the workflow version the
client's draft is based on. A mismatch returns 409 workflow_version_conflict
before anything is written, so a second tab can no longer replace a save it
never saw. The existing lock and compare-and-swap checks stay in place; the
guarded update already matches on the loaded version, which makes the check
atomic.

The designer sends the version it synced from the server and advances it after
each save or publish. On a conflict it keeps the draft, shows a message and
stops autosave until the workflow is reloaded. CLI, MCP, the load-test client
and the admin scripts send the version they read.

Fixes #609

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Sev7eNup
Sev7eNup merged commit 6fae41a into main Oct 24, 2026
17 checks passed
@Sev7eNup
Sev7eNup deleted the fix/stale-workflow-save-conflict branch October 24, 2026 19:08
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.

Stale editor tabs overwrite previously saved workflow changes

1 participant