File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -181,10 +181,13 @@ async function runtimeConfig() {
181181 }
182182
183183 const { data } = await apiService . get ( runtimeConfigUrl . toString ( ) , apiConfig ) ;
184+ if ( ! data || typeof data !== 'object' || Array . isArray ( data ) ) {
185+ throw new TypeError ( 'Runtime config must be a valid JSON object.' ) ;
186+ }
184187 mergeSiteConfig ( data , { limitAppMergeToConfig : true } ) ;
185188 }
186189 } catch ( error ) {
187- console . error ( 'Error with config API' , error . message ) ;
190+ console . error ( 'Error with config API: ' , error . message ) ;
188191 }
189192}
190193
Original file line number Diff line number Diff line change @@ -377,7 +377,7 @@ describe('initialize', () => {
377377 } ) ;
378378
379379 expect ( configureCache ) . toHaveBeenCalled ( ) ;
380- expect ( console . error ) . toHaveBeenCalledWith ( 'Error with config API' , 'Api fails' ) ;
380+ expect ( console . error ) . toHaveBeenCalledWith ( 'Error with config API: ' , 'Api fails' ) ;
381381 expect ( configureLogging ) . toHaveBeenCalledWith ( NewRelicLoggingService , { config } ) ;
382382 expect ( configureAuth ) . toHaveBeenCalledWith ( AxiosJwtAuthService , {
383383 loggingService : getLoggingService ( ) ,
You can’t perform that action at this time.
0 commit comments