Skip to content

Commit 3216f87

Browse files
Merge pull request opendatahub-io#1557 from pnaik1/issue-1522
Uploading a malformed pipeline yaml results in a blank page
2 parents ce510e6 + ea53266 commit 3216f87

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

frontend/src/concepts/pipelines/topology/core/PipelineVisualizationSurface.tsx

+30-9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import {
1111
VisualizationSurface,
1212
getSpacerNodes,
1313
} from '@patternfly/react-topology';
14+
import { EmptyState, EmptyStateBody, EmptyStateIcon, Title } from '@patternfly/react-core';
15+
import { ExclamationCircleIcon } from '@patternfly/react-icons';
1416

1517
type PipelineVisualizationSurfaceProps = {
1618
nodes: PipelineNodeModel[];
@@ -22,23 +24,42 @@ const PipelineVisualizationSurface: React.FC<PipelineVisualizationSurfaceProps>
2224
selectedIds,
2325
}) => {
2426
const controller = useVisualizationController();
25-
27+
const [error, setError] = React.useState<Error | null>();
2628
React.useEffect(() => {
2729
// PF Bug
2830
// TODO: Pipeline Topology weirdly doesn't set a width and height on spacer nodes -- but they do when using finally spacer nodes
2931
const spacerNodes = getSpacerNodes(nodes).map((s) => ({ ...s, width: 1, height: 1 }));
3032
const renderNodes = [...spacerNodes, ...nodes];
3133
// TODO: We can have a weird edge issue if the node is off by a few pixels vertically from the center
3234
const edges = getEdgesFromNodes(renderNodes);
33-
34-
controller.fromModel(
35-
{
36-
nodes: renderNodes,
37-
edges,
38-
},
39-
true,
40-
);
35+
try {
36+
controller.fromModel(
37+
{
38+
nodes: renderNodes,
39+
edges,
40+
},
41+
true,
42+
);
43+
} catch (error) {
44+
if (error instanceof Error) {
45+
setError(error);
46+
} else {
47+
// eslint-disable-next-line no-console
48+
console.error('Unknown error occurred rendering Pipeline Graph', error);
49+
}
50+
}
4151
}, [controller, nodes]);
52+
if (error) {
53+
return (
54+
<EmptyState data-id="error-empty-state">
55+
<EmptyStateIcon icon={ExclamationCircleIcon} />
56+
<Title headingLevel="h4" size="lg">
57+
Incorrect pipeline definition
58+
</Title>
59+
<EmptyStateBody>{error.message}</EmptyStateBody>
60+
</EmptyState>
61+
);
62+
}
4263

4364
return (
4465
<TopologyView

0 commit comments

Comments
 (0)