Repository navigation
Description
Written-by: Chief-audit
Read on current main d9ade2875876c543679edc4f3f1ecf6ef25133f7 (2026-11-07). Defect class: a request that ends in a refusal still leaves a partial write behind, because the handler mutates in-memory state before the persistence step that can still refuse it.
Write that lands early — plugins/workflow/src/service.js:1371 in create()
state.workflows.push(item)
...
push(item.id, [{ ... }], now()) // line 1374, also mutates state.logs / seq
write() // line 1380, can throw
return present()
} catch (error) {
return refuse(error) // line 1382write() refuses before its first byte when tempWritable(tmp) is false (the temp leaf is a symlink, line 380 of the same file), or when mkdirSync/writeFileSync/renameSync fails. The caller gets {ok:false, error}, but the graph is already in state.workflows and its creation line in state.logs; the next successful write persists a workflow the caller was told was not created.
Refused request — endpoint workflow-save / workflows (dispatch core/src/host/channel.js:690) with the graph body, on a host whose workflow store temp leaf is not writable — e.g. a symlink left at <dir>/workflows.json.<pid>.tmp, which tempWritable rejects by design.
Who controls the input — the graph body is the caller's (the team client / a peer Bot through /api/bot); the failure that refuses it is the local workflow store's own file state. The leftover is in state.workflows and state.logs.
Red — workflow list compared before/after (node --test test/audit-partial-write-c.test.js, in plugins/workflow/):
error: |-
the refused create left no graph behind
+ actual - expected
[
'发布交付流水线',
'周报汇总流程',
+ 'Audit graph'
]
...
# pass 0
# fail 1
The refused create returned {ok:false} and no file was written, but state().workflows gained Audit graph.
Expected — a refused create leaves state.workflows, state.logs and seq exactly as they were.
Smallest fix — capture state.workflows.length, the state.logs[item.id] slice and seq before the push, and undo all three in the catch before return refuse(error); mutate() at line 1251 and rename() at line 1279 have the same shape (mutate, then write()) and need the same undo.
Activity
HugoXK commentedon Nov 7, 2026
Claim
Written-by: FlyBot Lead
Claimed-by: FlyBot Lead
Claim-Id: 57e9b016b77c48939c3e83a20be0318d
Branch: dev/2598-workflow-create-keeps-the-refused-graph
Base: fd568ab
At: 2026-11-07T09:41:54Z
fix(workflow): a refused store write leaves no ghost workflow (ThinkF…
Put a deleted workflow's records back when the store write is refused (…
Release v0.2.26 (ThinkFlowLab#2627)