@@ -324,6 +324,17 @@ function Chart({
324324 }
325325 } , [ triggerQuery , runQuery ] ) ;
326326
327+ const isAwaitingDatasource = useCallback (
328+ ( queryResponse : ChartErrorType ) =>
329+ ! queryResponse ?. errors ?. [ 0 ] &&
330+ ! queryResponse ?. message &&
331+ chartAlert !== undefined &&
332+ chartAlert !== NONEXISTENT_DATASET &&
333+ datasource === PLACEHOLDER_DATASOURCE &&
334+ datasetsStatus !== ResourceStatus . Error ,
335+ [ chartAlert , datasetsStatus , datasource ] ,
336+ ) ;
337+
327338 const renderErrorMessage = useCallback (
328339 ( queryResponse : ChartErrorType ) => {
329340 const error = queryResponse ?. errors ?. [ 0 ] ;
@@ -332,14 +343,7 @@ function Chart({
332343 // if datasource is still loading, don't render JS errors
333344 // but always show backend API errors (structured or message-only)
334345 // so users can see real issues like auth failures
335- if (
336- ! error &&
337- ! queryResponse ?. message &&
338- chartAlert !== undefined &&
339- chartAlert !== NONEXISTENT_DATASET &&
340- datasource === PLACEHOLDER_DATASOURCE &&
341- datasetsStatus !== ResourceStatus . Error
342- ) {
346+ if ( isAwaitingDatasource ( queryResponse ) ) {
343347 return (
344348 < Styles
345349 key = { chartId }
@@ -370,9 +374,8 @@ function Chart({
370374 chartId ,
371375 chartStackTrace ,
372376 dashboardId ,
373- datasetsStatus ,
374- datasource ,
375377 height ,
378+ isAwaitingDatasource ,
376379 ] ,
377380 ) ;
378381
@@ -506,18 +509,26 @@ function Chart({
506509
507510 if ( datasource ?. metadata_error ) {
508511 return (
509- < ErrorContainer height = { height } >
512+ < ErrorContainer className = "chart-container" height = { height } >
510513 { renderErrorMessage ( { message : datasource . metadata_error } ) }
511514 </ ErrorContainer >
512515 ) ;
513516 }
514517
515518 if ( chartStatus === 'failed' ) {
519+ const failedResponses = (
520+ queriesResponse ?. length ? queriesResponse : [ { } ]
521+ ) as ChartErrorType [ ] ;
516522 return (
517- < ErrorContainer height = { height } >
518- { queriesResponse ?. map ( item =>
519- renderErrorMessage ( item as ChartErrorType ) ,
520- ) }
523+ < ErrorContainer
524+ className = {
525+ failedResponses . some ( item => isAwaitingDatasource ( item ) )
526+ ? undefined
527+ : 'chart-container'
528+ }
529+ height = { height }
530+ >
531+ { failedResponses . map ( item => renderErrorMessage ( item ) ) }
521532 </ ErrorContainer >
522533 ) ;
523534 }
0 commit comments