fix: handle missing TaskPage key in workflow activity mutation#243
fix: handle missing TaskPage key in workflow activity mutation#243retran wants to merge 5 commits intomendixlabs:mainfrom
Conversation
When setting PAGE on a workflow activity where the TaskPage BSON key is absent (not just nil), dSet silently failed because it only updates existing keys. Added replaceActivity helper that appends the key to the activity document and replaces it in the BSON tree by match. Three cases now handled correctly: - TaskPage exists with value: update Page field in place - TaskPage exists with nil value: replace via dSet - TaskPage absent: append key, replace activity in tree
AI Code ReviewWhat Looks Good
RecommendationApprove. This is a minimal, targeted bug fix that resolves the silent failure when setting PAGE on workflow activities with missing TaskPage keys. The change follows existing patterns, updates tests appropriately, and maintains backward compatibility. No checklist violations apply as this is a backend-only fix without MDL syntax changes. Automated review via OpenRouter (Nemotron Super 120B) — workflow source |
There was a problem hiding this comment.
Pull request overview
Fixes a workflow mutation edge case where setting the PAGE property on an activity silently failed when the TaskPage BSON key was entirely absent (not present with nil).
Changes:
- Updates
SetActivityProperty(..., "PAGE", ...)to handle the “missing key” case by appendingTaskPageand reattaching the updated activity into the workflow BSON tree. - Adds
replaceActivity/replaceActivityRecursivehelpers to replace an activity inFlow.Activities(including nested flows) by matching$ID. - Updates the existing regression test to assert correct behavior when
TaskPageis missing.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
mdl/backend/mpr/workflow_mutator.go |
Adds recursive activity replacement helper and uses it when TaskPage key is absent during PAGE mutation. |
mdl/backend/mpr/workflow_mutator_test.go |
Converts the prior “documents the bug” test into a true regression assertion for the missing-key case. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
AI Code ReviewCritical Issues
Moderate Issues
Minor Issues
What Looks Good
RecommendationApprove - This is a well-scoped bug fix that properly addresses the root cause with comprehensive test coverage. The implementation is clean, follows existing code patterns, and handles edge cases including nested activities. No checklist violations found. Automated review via OpenRouter (Nemotron Super 120B) — workflow source |
There was a problem hiding this comment.
Pull request overview
Fixes workflow activity PAGE mutation so TaskPage is correctly set even when the TaskPage key is entirely absent from the activity BSON (not just present with a nil value), by replacing the updated activity back into the workflow tree by $ID.
Changes:
- Update
SetActivityProperty(PAGE)to handle missingTaskPagekeys by appending the field and replacing the activity in the workflow BSON tree. - Add/adjust regression tests to assert
TaskPage.Pageis set for both missing-key and nested-subflow cases. - Minor formatting/whitespace cleanup in several Go files/tests.
Reviewed changes
Copilot reviewed 4 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
mdl/backend/mpr/workflow_mutator.go |
Adds replaceActivity / recursive traversal to replace an updated activity by $ID when appending new keys. |
mdl/backend/mpr/workflow_mutator_test.go |
Updates regression assertion for missing TaskPage key and adds a nested subflow test case. |
mdl/backend/mpr/backend.go |
Formatting-only changes to method bodies/signatures. |
mdl/backend/mpr/convert_roundtrip_test.go |
Removes trailing whitespace line at EOF. |
mdl/executor/widget_registry.go |
Formatting-only alignment changes to struct fields. |
mdl/types/edmx_test.go |
Formatting-only alignment changes in test struct definition. |
mdl/types/id_test.go |
Formatting-only alignment change in test case list. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
AI Code ReviewCritical IssuesNone found. Moderate IssuesNone found. Minor Issues
What Looks Good
RecommendationApprove. The fix is correct, well-tested, and maintains backward compatibility. Minor formatting noise doesn't warrant blocking merge. The PR successfully resolves the silent failure when setting PAGE on workflow activities with missing TaskPage keys. Automated review via OpenRouter (Nemotron Super 120B) — workflow source |
There was a problem hiding this comment.
Pull request overview
Fixes workflow activity PAGE mutation to correctly set TaskPage.Page even when the TaskPage BSON key is entirely absent (not just present with nil), by appending the missing key and replacing the activity in the workflow BSON tree via $ID match.
Changes:
- Add
replaceActivity/replaceActivityRecursiveto support replacing an updated activity document back into the workflow BSON tree (including nested sub-flows). - Update/strengthen workflow mutator tests to assert the fixed behavior for missing
TaskPage(including a nested sub-flow regression test). - Apply minor formatting/gofmt cleanup in a few files.
Reviewed changes
Copilot reviewed 4 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| mdl/types/id_test.go | Minor formatting alignment in test table. |
| mdl/types/edmx_test.go | Minor struct field alignment in test definitions. |
| mdl/executor/widget_registry.go | Minor field alignment formatting. |
| mdl/backend/mpr/workflow_mutator_test.go | Update regression test to assert fixed behavior; add nested sub-flow coverage for recursive replacement. |
| mdl/backend/mpr/workflow_mutator.go | Implement missing-key handling for PAGE by appending TaskPage and replacing the activity by $ID (including nested flows). |
| mdl/backend/mpr/convert_roundtrip_test.go | Remove trailing blank line. |
| mdl/backend/mpr/backend.go | Formatting/gofmt changes for method layout. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
AI Code ReviewCritical Issues
Moderate Issues
Minor Issues
What Looks Good
RecommendationApprove the PR. The fix correctly resolves the reported issue with appropriate test coverage and maintains architectural boundaries. Minor style inconsistencies are trivial and do not warrant blocking merge. The nested sub-flow test could benefit from a clarifying comment but is functionally sound. All checklist items pass: no syntax changes (so MDL/full-stack sections N/A), no duplication, proper test coverage, and scope is strictly focused on the bug fix. Automated review via OpenRouter (Nemotron Super 120B) — workflow source |
There was a problem hiding this comment.
Pull request overview
Fixes workflow activity PAGE mutation so it correctly sets TaskPage even when the TaskPage BSON key is completely absent (not just present with nil), by appending the missing key and replacing the activity document in the workflow tree by $ID.
Changes:
- Update
SetActivityProperty(..., "PAGE", ...)to handle the “TaskPage key absent” case via append + activity replacement. - Add
replaceActivity/replaceActivityRecursivehelper to replace an activity in nested flows by$ID. - Strengthen regression tests to assert correct behavior for missing
TaskPage, including a nested sub-flow scenario; plus minor formatting cleanups elsewhere.
Reviewed changes
Copilot reviewed 4 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
mdl/backend/mpr/workflow_mutator.go |
Implements missing-TaskPage handling and adds activity replacement helper for appended keys. |
mdl/backend/mpr/workflow_mutator_test.go |
Updates regression expectations and adds nested sub-flow coverage for the recursive replacement path. |
mdl/backend/mpr/backend.go |
Formatting-only changes (multi-line method bodies). |
mdl/backend/mpr/convert_roundtrip_test.go |
Removes trailing whitespace/blank line. |
mdl/executor/widget_registry.go |
Formatting-only alignment changes. |
mdl/types/id_test.go |
Formatting-only alignment change in test table. |
mdl/types/edmx_test.go |
Formatting-only alignment change in test struct fields. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
AI Code ReviewCritical Issues
Moderate Issues
Minor Issues
What Looks Good
Recommendation Automated review via OpenRouter (Nemotron Super 120B) — workflow source |
There was a problem hiding this comment.
Pull request overview
Fixes workflow activity PAGE mutation so TaskPage is set correctly even when the TaskPage key is entirely absent from an activity BSON document (not just present with a nil value). This prevents silently-lost page references when mutating newly-created / incomplete activity shapes.
Changes:
- Update
SetActivityProperty(PAGE)to append a missingTaskPagekey and replace the activity in the workflow BSON tree by$ID. - Add recursive
replaceActivitylogic to support nested sub-flow activity replacement. - Strengthen/extend regression tests (including a nested sub-flow case) and apply minor formatting cleanups.
Reviewed changes
Copilot reviewed 4 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
mdl/backend/mpr/workflow_mutator.go |
Implements missing-TaskPage handling and adds recursive activity replacement by $ID. |
mdl/backend/mpr/workflow_mutator_test.go |
Updates regression test expectations and adds nested sub-flow coverage for the replacement path. |
mdl/backend/mpr/backend.go |
Formatting-only changes (multi-line method bodies). |
mdl/backend/mpr/convert_roundtrip_test.go |
Removes trailing blank line (formatting). |
mdl/executor/widget_registry.go |
Field alignment/formatting. |
mdl/types/edmx_test.go |
Test struct field alignment/formatting. |
mdl/types/id_test.go |
Test case alignment/formatting. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Review: PR #243 — fix: handle missing TaskPage key in workflow activity mutationVerdict: Approve with suggestions — clean, well-scoped bug fix with solid test coverage. The root cause is correctly diagnosed and the fix is the right approach. OverviewWhen Code Quality
if !dSet(actDoc, "TaskPage", pageRef) {
actDoc = append(actDoc, bson.E{Key: "TaskPage", Value: pageRef})
m.replaceActivity(actDoc) // ← no return value; silent on failure
}If
Test Coverage
Formatting / Unrelated ChangesThe Suggestions
|
Summary
When setting PAGE on a workflow activity where the TaskPage BSON key is absent (not just nil),
dSetsilently failed because it only updates existing keys — the page reference was lost.This adds a
replaceActivityhelper that appends the missing key to the activity document and replaces it in the workflow's BSON tree by$IDmatch.Three cases now handled correctly:
dSet(unchanged)The existing regression test (
TestWorkflowMutator_SetActivityProperty_Page_MissingKey) now asserts correct behavior instead of documenting the bug.