@@ -44,35 +44,55 @@ const PANEL_TITLE = 'Inspect flows';
44
44
* The base Tools component for performing ingest and search, viewing resources, and debugging.
45
45
*/
46
46
export function Tools ( props : ToolsProps ) {
47
- // error message state
47
+ // error message states. Error may come from several different sources.
48
48
const { opensearch, workflows } = useSelector ( ( state : AppState ) => state ) ;
49
49
const opensearchError = opensearch . errorMessage ;
50
50
const workflowsError = workflows . errorMessage ;
51
- const [ curErrorMessage , setCurErrorMessage ] = useState < string > ( '' ) ;
51
+ const {
52
+ ingestPipeline : ingestPipelineErrors ,
53
+ searchPipeline : searchPipelineErrors ,
54
+ } = useSelector ( ( state : AppState ) => state . errors ) ;
55
+ const [ curErrorMessages , setCurErrorMessages ] = useState < string [ ] > ( [ ] ) ;
52
56
53
- // auto-navigate to errors tab if a new error has been set as a result of
54
- // executing OpenSearch or Flow Framework workflow APIs, or from the workflow state
55
- // (note that if provision/deprovision fails, there is no concrete exception returned at the API level -
56
- // it is just set in the workflow's error field when fetching workflow state)
57
+ // Propagate any errors coming from opensearch API calls, including ingest/search pipeline verbose calls.
57
58
useEffect ( ( ) => {
58
- setCurErrorMessage ( opensearchError ) ;
59
- if ( ! isEmpty ( opensearchError ) ) {
60
- props . setSelectedTabId ( INSPECTOR_TAB_ID . ERRORS ) ;
59
+ if (
60
+ ! isEmpty ( opensearchError ) ||
61
+ ! isEmpty ( ingestPipelineErrors ) ||
62
+ ! isEmpty ( searchPipelineErrors )
63
+ ) {
64
+ if ( ! isEmpty ( opensearchError ) ) {
65
+ setCurErrorMessages ( [ opensearchError ] ) ;
66
+ } else if ( ! isEmpty ( ingestPipelineErrors ) ) {
67
+ setCurErrorMessages ( [
68
+ 'Data not ingested. Errors found with the following ingest processor(s):' ,
69
+ ...Object . values ( ingestPipelineErrors ) . map ( ( value ) => value . errorMsg ) ,
70
+ ] ) ;
71
+ } else if ( ! isEmpty ( searchPipelineErrors ) ) {
72
+ setCurErrorMessages ( [
73
+ 'Errors found with the following search processor(s)' ,
74
+ ...Object . values ( searchPipelineErrors ) . map ( ( value ) => value . errorMsg ) ,
75
+ ] ) ;
76
+ }
77
+ } else {
78
+ setCurErrorMessages ( [ ] ) ;
61
79
}
62
- } , [ opensearchError ] ) ;
80
+ } , [ opensearchError , ingestPipelineErrors , searchPipelineErrors ] ) ;
63
81
82
+ // Propagate any errors coming from the workflow, either runtime from API call, or persisted in the indexed workflow itself.
64
83
useEffect ( ( ) => {
65
- setCurErrorMessage ( workflowsError ) ;
66
- if ( ! isEmpty ( workflowsError ) ) {
67
- props . setSelectedTabId ( INSPECTOR_TAB_ID . ERRORS ) ;
68
- }
84
+ setCurErrorMessages ( ! isEmpty ( workflowsError ) ? [ workflowsError ] : [ ] ) ;
69
85
} , [ workflowsError ] ) ;
70
86
useEffect ( ( ) => {
71
- setCurErrorMessage ( props . workflow ?. error || '' ) ;
72
- if ( ! isEmpty ( props . workflow ?. error ) ) {
87
+ setCurErrorMessages ( props . workflow ?. error ? [ props . workflow . error ] : [ ] ) ;
88
+ } , [ props . workflow ?. error ] ) ;
89
+
90
+ // auto-navigate to errors tab if new errors have been found
91
+ useEffect ( ( ) => {
92
+ if ( curErrorMessages . length > 0 ) {
73
93
props . setSelectedTabId ( INSPECTOR_TAB_ID . ERRORS ) ;
74
94
}
75
- } , [ props . workflow ?. error ] ) ;
95
+ } , [ curErrorMessages ] ) ;
76
96
77
97
// auto-navigate to ingest tab if a populated value has been set, indicating ingest has been ran
78
98
useEffect ( ( ) => {
@@ -136,7 +156,7 @@ export function Tools(props: ToolsProps) {
136
156
/>
137
157
) }
138
158
{ props . selectedTabId === INSPECTOR_TAB_ID . ERRORS && (
139
- < Errors errorMessage = { curErrorMessage } />
159
+ < Errors errorMessages = { curErrorMessages } />
140
160
) }
141
161
{ props . selectedTabId === INSPECTOR_TAB_ID . RESOURCES && (
142
162
< Resources workflow = { props . workflow } />
0 commit comments