Skip to content

DYN-10693: Keep the FunctionNotFound warning across Code Block Node edits - #17267

Open
RobertGlobant20 wants to merge 1 commit into
masterfrom
DYN-10693_Fix_lost_FunctionNotFound_warning_on_CBN_edit
Open

DYN-10693: Keep the FunctionNotFound warning across Code Block Node edits#17267
RobertGlobant20 wants to merge 1 commit into
masterfrom
DYN-10693_Fix_lost_FunctionNotFound_warning_on_CBN_edit

Conversation

@RobertGlobant20

Copy link
Copy Markdown
Contributor

Purpose

Follow-up fix for DYN-10693, reported by Neal Burnham during testing of #17224 on 4.3.0.5770:

In preliminary testing with 4.3.0.5770 the fix is validated for a "first time in" case, however if the cbn is edited and re-executed the warning state vanishes: INCORRECT. The nature of the edit is un-important: any edit will cause the flaw.

#17224 only covered the graph-open path. Opening a graph runs the two-pass compile (ReCompileCodeBlockNodesForFunctionDefinitions), and the deferred re-check in RecompileCodeBlockAST emits the warning correctly. Editing a Code Block Node recompiles it in a single pass, where the warning was lost for a different — and older — reason that #17224 made visible.

Root cause

A Code Block Node's previously compiled def is still active in the shared precompilation core when the node is recompiled after an edit:

  1. ProcedureTable.Append finds an active duplicate and returns kInvalidIndex.
  2. Code generation logs FunctionAlreadyDefined and sets funcDef.skipMe = true (ProtoAssociative/CodeGen.cs:3785).
  3. FunctionAlreadyDefined is deliberately filtered out of Code Block Node warnings (CodeBlockNode.cs:870), so nothing is surfaced.
  4. DfsTraverse returns early on skipMe (ProtoAssociative/CodeGen.cs:6050), so the function body is never traversed — the unresolved call inside it is never visited and no FunctionNotFound is raised.
  5. ProcessCodeDirect has already called ClearErrorsAndWarnings(), so the warning shown at graph open simply disappears.

This is not specific to FunctionNotFound: any diagnostic inside a redefined function body was being dropped on recompile.

Fix

Deactivate the node's own definitions in ProcessCode before recompiling, so ProcedureTable.Append takes its !existingProcNode.IsActive branch and replaces the stale entry in place. The body is compiled again and its warnings are reported. This mirrors what LiveRunner.UndefineFunctions already does for redefined subtrees.

Also guards UndefineFunctionDefinitions against a null ParseParam, which is the state on a node's first compile.

Behavior change worth a look during review: a Code Block Node that renames or deletes a def now leaves the old name genuinely undefined, instead of leaving a permanently-registered definition behind. That is more correct, but it does change what other Code Block Nodes resolve when they next recompile.

Declarations

Check these if you believe they are true

No public API surface changes — UndefineFunctionDefinitions is internal and already existed.

Release Notes

Fixed an issue where the "Method not found" warning on a Code Block Node disappeared after the node was edited and the graph re-executed, leaving broken code silently returning null.

Reviewers

@jasonstratton (reviewed and merged #17224)

@edwin-vasquez-ucaldas

Notes for testers — the repro is the same as DYN-10693, with an extra step:

  1. Open a graph containing a Code Block Node with an unresolved call inside a def body, e.g. def tostr(x) { return = ToString(x); }; tostr(3.1415);
  2. Confirm the "Method 'ToString()' not found" warning appears.
  3. Make any edit to the Code Block Node (changing the argument value is enough) and re-run.
  4. The warning must still be shown. Before this fix it disappeared.

Also worth confirming that valid forward references still do not warn after an edit, both within one Code Block Node and across two.

Testing performed

  • New regression tests in CodeBlockNodeTests: FunctionCall_KeepsWarning_WhenCodeBlockIsEditedAfterUnresolvedCallInBody and FunctionCall_NoWarning_WhenForwardReferenceInSameCodeBlockIsEdited.
  • All 11 FunctionCall_* / ImperativeFunctionCall_* tests pass, plus the full CodeBlockNodeTests fixture (79 tests) and CodeBlockNodeTests2 / DynamoDefects / CallsiteTests / CoreTests (109 tests).
  • A wider Name~Function|Cbn|CodeBlock sweep surfaced 4 failures (UsingFunctionObject01, UsingFunctionObject02, TestMigration_Core_Functions, ImperativeArrayIndexingInCodeBlockToCode). These were verified to fail identically on clean master with this change stashed, so they are pre-existing and unrelated.

FYIs

Neal Burnham (reported the regression in testing)

🤖 Generated with Claude Code

The DYN-10693 fix reported unresolved calls inside a code block node
function body only on the graph-open path, which runs the two-pass
compile and drains the deferred-resolution buffer. Editing a code block
node instead recompiles it in a single pass, and there the warning was
lost for a different reason.

A code block node's previously compiled definitions stay active on the
shared precompilation core, so re-appending them is rejected as a
redefinition. Code generation then logs FunctionAlreadyDefined - which
code block nodes deliberately filter out - and marks the definition
skipMe, so DfsTraverse never walks the body. Every diagnostic inside the
body is silently dropped, and because ProcessCodeDirect has already
cleared the node's errors and warnings, the warning shown when the graph
was opened simply vanished on any edit.

Deactivate the node's own definitions before recompiling so
ProcedureTable.Append replaces the stale entry instead of rejecting it.
The body is compiled again and its warnings are reported. This mirrors
what LiveRunner.UndefineFunctions already does for redefined subtrees.

Also guard UndefineFunctionDefinitions against a null ParseParam, which
is the state on a node's first compile.

Adds regression coverage for the edit path: an unresolved call inside a
function body keeps warning after an edit, and a forward reference
within the same code block node still does not warn after an edit.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 3, 2026 22:08

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the ticket for this pull request: https://jira.autodesk.com/browse/DYN-10693

@RobertGlobant20

Copy link
Copy Markdown
Contributor Author

GIF showing the expected behavior
ToStringWarningEdgeCase

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a long-standing Code Block Node (CBN) recompilation issue where diagnostics inside redefined function bodies (notably FunctionNotFound) could disappear after editing the CBN, due to the node’s prior function definitions remaining active in the shared precompilation core.

Changes:

  • Deactivate a CBN’s previously registered function definitions before recompiling its edited code, so function bodies are traversed again and their diagnostics are preserved.
  • Add a null-guard in UndefineFunctionDefinitions for first-compile scenarios where ParseParam/ParsedNodes may not be available.
  • Add regression tests ensuring warnings persist across edits and valid forward references do not start warning after edits.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
test/DynamoCoreTests/CodeBlockNodeTests.cs Adds regression coverage for warning persistence across CBN edits and for forward-reference non-warning behavior after edits.
src/DynamoCore/Graph/Nodes/CodeBlockNode.cs Ensures prior CBN function definitions are deactivated before recompilation to avoid “skipMe” codegen paths dropping diagnostics; adds null guard for ParseParam.

@sonarqubecloud

sonarqubecloud Bot commented Aug 3, 2026

Copy link
Copy Markdown

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.

2 participants