@@ -23,6 +23,8 @@ import type {
2323} from '../../../../common' ;
2424import { pkgToPkgKey } from '../registry' ;
2525
26+ import { appContextService } from '../../app_context' ;
27+
2628import { getArchiveEntry , setArchiveEntry , setArchiveFilelist , setPackageInfo } from './index' ;
2729import type { ArchiveEntry } from './index' ;
2830import { parseAndVerifyPolicyTemplates , parseAndVerifyStreams } from './validation' ;
@@ -165,15 +167,35 @@ export const getEsPackage = async (
165167 references : PackageAssetReference [ ] ,
166168 savedObjectsClient : SavedObjectsClientContract
167169) => {
170+ const logger = appContextService . getLogger ( ) ;
168171 const pkgKey = pkgToPkgKey ( { name : pkgName , version : pkgVersion } ) ;
169172 const bulkRes = await savedObjectsClient . bulkGet < PackageAsset > (
170173 references . map ( ( reference ) => ( {
171174 ...reference ,
172175 fields : [ 'asset_path' , 'data_utf8' , 'data_base64' ] ,
173176 } ) )
174177 ) ;
178+ const errors = bulkRes . saved_objects . filter ( ( so ) => so . error || ! so . attributes ) ;
175179 const assets = bulkRes . saved_objects . map ( ( so ) => so . attributes ) ;
176180
181+ if ( errors . length ) {
182+ const resolvedErrors = errors . map ( ( so ) =>
183+ so . error
184+ ? { type : so . type , id : so . id , error : so . error }
185+ : ! so . attributes
186+ ? { type : so . type , id : so . id , error : { error : `No attributes retrieved` } }
187+ : { type : so . type , id : so . id , error : { error : `Unknown` } }
188+ ) ;
189+
190+ logger . warn (
191+ `Failed to retrieve ${ pkgName } -${ pkgVersion } package from ES storage. bulkGet failed for assets: ${ JSON . stringify (
192+ resolvedErrors
193+ ) } `
194+ ) ;
195+
196+ return undefined ;
197+ }
198+
177199 const paths : string [ ] = [ ] ;
178200 const entries : ArchiveEntry [ ] = assets . map ( packageAssetToArchiveEntry ) ;
179201 entries . forEach ( ( { path, buffer } ) => {
0 commit comments