fix(ui): render forward-referenced DAG dependencies in Graph Viewer#16295
Open
myzk-a wants to merge 1 commit into
Open
fix(ui): render forward-referenced DAG dependencies in Graph Viewer#16295myzk-a wants to merge 1 commit into
myzk-a wants to merge 1 commit into
Conversation
Signed-off-by: myzk-a <rorosocksxion@gmail.com>
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.
Supersedes #16119
Motivation
Opening the Graph tab for a Workflow / WorkflowTemplate / ClusterWorkflowTemplate / CronWorkflow whose DAG contains a forward reference crashes the UI with:
A forward reference is a DAG task that
dependson a sibling task defined later in thetasksarray. Argo's controller does not require tasks to be declared in topological order, so these workflows run perfectly fine — but the Graph tab is unusable for them.populateGraphFromWorkflowbuilds the graph in a single pass: for each task it creates the node and then immediately resolves that task's dependencies. When a task references a dependency that has not been created yet (forward reference, or a name that does not match a sibling task),graph.nodes.get(dependancyName)returnsundefinedand reading.genreon it throws.Reproduction
Save this template and open its Graph tab → the view crashes with
reading 'genre'.Modifications
populateGraphFromWorkflow(ui/src/shared/components/editors/graph-viewer.tsx), resolve the dependency's genre from the template model (template.dag.tasks+getTaskGenre) instead of from the partially-built graph.createNodestores for that task.build → deploy) is created.Why not the guard approach (#16119)?
#16119 guards the
undefinedlookup andreturns early, which stops the crash but drops the forward-reference edge, leaving an orphan node (the dependent task has no incoming edge). Resolving the genre from the model fixes the crash and renders the edge correctly, so it is strictly better for this case.Verification
cd ui && yarn jest graph-viewer→ 25 passed (includes the new forward-reference edge test).cd ui && yarn lint(eslint + tsc) → clean.main(reading 'genre'throw) and on fix(ui): guard missing DAG dependency nodes in GraphViewer #16119's guard approach (missingbuild → deployedge), and green with this change.make start UI=true): applied the reproductionWorkflowTemplateabove, opened its Graph tab. Before the fix the tab crashed withCannot read properties of undefined (reading 'genre'); after the fix the graph renders and thebuild → deployedge is drawn correctly (screenshot below).Graph tab after the fix (the

build → deployedge is rendered):Documentation
Not needed — this is a bug fix for existing behavior with no user-facing API or configuration change.
AI
Generative AI (Claude Code) was used as a pair-programming assistant to investigate the root cause, weigh fix approaches, and draft this PR description and the commit message. The code change and the test were authored and reviewed by me.