[Fix-18448][UI] Add null-check for workflowDefinition in dag component computed properties - #18455
Closed
KaiSong-UK wants to merge 1 commit into
Closed
Conversation
…t startDisplay and menuDisplay computed properties Closes apache#18448 In dag/index.tsx, startDisplay and menuDisplay computed properties use the non-null assertion operator (props.definition!) which has no runtime effect. When props.definition.workflowDefinition is undefined, accessing .releaseState throws TypeError. This fix replaces the non-null assertion with optional chaining (?.) to safely handle the case where workflowDefinition is undefined, matching the existing pattern used in dag-toolbar.tsx.
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.
Purpose
Fixes #18448
When the DAG component renders, the \startDisplay\ and \menuDisplay\ computed properties throw \TypeError: Cannot read properties of undefined (reading 'releaseState')\ because \workflowDefinition\ can be \undefined\ on the \props.definition\ object.
Root Cause
In \dag/index.tsx, \startDisplay\ and \menuDisplay\ use:
\\ s
props.definition!.workflowDefinition.releaseState
\\
The non-null assertion operator (!) has no runtime effect. When \props.definition.workflowDefinition\ is \undefined, accessing .releaseState\ throws \TypeError.
Changes
Replace non-null assertions with optional chaining (?.) for safe property access:
\\diff
\\
\\diff
\\
This matches the pattern already used in \dag-toolbar.tsx\ (\props.definition?.workflowDefinition?.releaseState).