From 7f7eff567ce0a399458600c62ccd1f31f06e132b Mon Sep 17 00:00:00 2001 From: Marco polo Date: Wed, 11 Oct 2023 23:49:59 -0400 Subject: [PATCH] Handle undefined assetChecksAvailable in current session (#17170) ## Summary & Motivation If you access a session from localStorage from before this release then this property won't exist. We correctly use the existential operator (?.) in [other places ](https://github.com/dagster-io/dagster/blob/45c5a47480b8f712d5c4c51e74213626d5061b79/js_modules/dagster-ui/packages/ui-core/src/launchpad/LaunchpadSession.tsx#L209)but looks like we forgot to use it here. ## How I Tested These Changes 1. Switched to release-1.5.2 2. Made a new launchpad config 3. Switched back to release-1.5.3 and saw the error: 4. Screenshot 2023-10-11 at 11 28 22 PM 5. Switched to this branch and saw the error go away --- .../ui-core/src/app/ExecutionSessionStorage.tsx | 3 ++- .../ui-core/src/launchpad/LaunchpadSession.tsx | 16 +++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/js_modules/dagster-ui/packages/ui-core/src/app/ExecutionSessionStorage.tsx b/js_modules/dagster-ui/packages/ui-core/src/app/ExecutionSessionStorage.tsx index d4239e0a147ec..16e2da3dcdc6d 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/app/ExecutionSessionStorage.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/app/ExecutionSessionStorage.tsx @@ -43,7 +43,8 @@ export interface IExecutionSession { mode: string | null; needsRefresh: boolean; assetSelection: {assetKey: AssetKeyInput; opNames: string[]}[] | null; - assetChecksAvailable: Pick[]; + // Nullable for backwards compatibility + assetChecksAvailable?: Pick[]; includeSeparatelyExecutableChecks: boolean; solidSelection: string[] | null; solidSelectionQuery: string | null; diff --git a/js_modules/dagster-ui/packages/ui-core/src/launchpad/LaunchpadSession.tsx b/js_modules/dagster-ui/packages/ui-core/src/launchpad/LaunchpadSession.tsx index e390a580026fc..df74fe8280a40 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/launchpad/LaunchpadSession.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/launchpad/LaunchpadSession.tsx @@ -320,13 +320,15 @@ const LaunchpadSession: React.FC = (props) => { const [showChecks, setShowChecks] = React.useState< typeof currentSession.assetChecksAvailable | null >(null); - const includedChecks = currentSession.assetChecksAvailable.filter( - (a) => a.canExecuteIndividually === AssetCheckCanExecuteIndividually.REQUIRES_MATERIALIZATION, - ); - - const executableChecks = currentSession.assetChecksAvailable.filter( - (a) => a.canExecuteIndividually === AssetCheckCanExecuteIndividually.CAN_EXECUTE, - ); + const includedChecks = + currentSession.assetChecksAvailable?.filter( + (a) => a.canExecuteIndividually === AssetCheckCanExecuteIndividually.REQUIRES_MATERIALIZATION, + ) ?? []; + + const executableChecks = + currentSession.assetChecksAvailable?.filter( + (a) => a.canExecuteIndividually === AssetCheckCanExecuteIndividually.CAN_EXECUTE, + ) ?? []; const buildExecutionVariables = () => { if (!currentSession) {