Repository navigation
Keep step outputs and trigger events to plain data (#22) - #23
Merged
Merged
Conversation
TaskNotes attaches `basesData` (a Bases entry that reaches the Obsidian App) to the cached TaskInfo once a task is rendered in a Bases view, and `tasks.get`/`tasks.patch` and task events hand that object over. The graph is circular, so any `$expr` that reads `steps` or `event` overflowed the stack in obsidian-bases-expression's `fromJs`, and the run log then failed with "Converting circular structure to JSON", hiding the real error. Add toWorkflowData, which copies values to plain data (plain objects, arrays, primitives and Dates; class instances, functions and cyclic back-references are dropped as JSON would), and apply it to the trigger payload and to every step output before they enter the run context. The run log serialises through the same function, so a stray runtime object can no longer stop the detail log from being written. Root cause diagnosed by konstantinopolka. Reported by rougeayrn (#22) and chrabia (TaskNotes #2119).
This was referenced Nov 10, 2026
This was referenced Nov 10, 2026
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.
Fixes #22. Related: callumalpass/tasknotes#2119, callumalpass/obsidian-bases-expression#7.
Cause
Credit to @konstantinopolka for the diagnosis. Once TaskNotes renders a task in a Bases view, it attaches
basesData(a Bases entry that reaches the ObsidianApp) to the cached TaskInfo. TaskNotes 4.17 returns that object fromtasks.get, from mutations such astasks.patch, and in task event payloads. The graph is circular, so:$exprthat readsstepsoreventoverflows the stack inobsidian-bases-expression'sfromJs("Maximum call stack size exceeded");RunLogService.writeDetailthen fails with "Converting circular structure to JSON", which hides the real error.Fix
src/workflowData.tswithtoWorkflowData, which copies a value to plain data. It keeps plain objects, arrays, primitives and Dates. It drops class instances, functions and back-references to an object still being copied, the same way JSON does. Repeated references that are not cycles are kept.WorkflowEngineapplies it to the trigger payload, which feedseventand the run detailtrigger, and to every step output (local steps and interop outputs) before the output enterssteps.*.RunLogServiceserialises the history line and the detail file through the same function. A stray runtime object can no longer stop the run log from being written.This doesn't depend on the TaskNotes or library changes. It fixes the issue on TaskNotes 4.17 with
obsidian-bases-expression0.2.0 as they are today.Tests
tests/issue-22-circular-step-output.test.tsuses a TaskInfo-like object carrying a circularbasesData. Before the fix, the step-output and event expressions fail with "Maximum call stack size exceeded" and the run log fails with "Converting circular structure to JSON". All 5 tests fail before the fix and pass after.tests/workflowData.test.tsadds unit tests for the converter.npm test(71 passed),npm run typecheck,npm run lintandnpm run buildall pass. I didn't verify this in Obsidian because no instance was running.