fix(bpm-core): keep the top-level manager fallback when custom fields are empty - #3
Merged
Conversation
… are empty
readManagerMemberIdFromInitiatorSnapshot returned as soon as customFields was
any record, so a snapshot shaped { customFields: {}, managerMemberId: '...' }
resolved to undefined and every ORG_MANAGER node reported "did not resolve to
a member id". That is exactly the shape the template designer preview sends,
so dry running any template with a "manager of the initiator" step always
failed.
Only take the custom-fields branch when it actually carries a manager id.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BVBYyU83KfmAeJGj6gGsVm
coollugi
force-pushed
the
fix/dry-run-manager-snapshot
branch
from
August 3, 2026 12:23
abd6bdd to
e8a0b96
Compare
Contributor
Author
|
base 已經從 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
問題
只要範本裡含有「發起人主管」關卡(
approverResolver.type === 'ORG_MANAGER'),從設計器按試跑一定失敗:範本本身沒問題 —— 發布後實際送出案件,主管會正常透過
manager_resolutions解析出來壞掉的只有預覽這條路,所以設計器的試跑按鈕對最常用的那個簽核來源等於不能用
根因
readManagerMemberIdFromInitiatorSnapshot依序找四個來源:managerChain、managerMemberIds、customFields.managerMemberId,最後才是頂層的managerMemberId第三步只要
customFields是任何物件就直接回傳:{}也是物件,所以空的customFields會短路成undefined,第四步永遠不會執行而設計器預覽組出來的 snapshot 正好就是這個形狀 ——
{ customFields: {}, managerMemberId: 'member-002', memberId: 'member-001', ... }—— 它刻意帶進來的頂層 id 反而永遠讀不到修法
只有在 custom fields 真的帶了 manager id 時才走那一條分支
測試
在
libs/bpm-core/src/lib/workflow-engine/workflow-engine.service.spec.ts新增兩個案例:customFields會往下落到頂層的managerMemberIdcustomFields.managerMemberId仍然優先於頂層的驗證過第一個是真的迴歸防護:只還原 source 的改動,它會紅
nx test bpm-core(21 suites/162 tests)/nx lint bpm-core/nx typecheck bpm-core全部通過備註
bpm-core-react那側的 snapshot 建構函式其實也可以改成把managerMemberId放進customFields裡但修讀取端是比較保險的選擇,任何送出這個形狀的呼叫端都能得到合理結果
🤖 Generated with Claude Code
https://claude.ai/code/session_01BVBYyU83KfmAeJGj6gGsVm