fix(appstore): handle App Store backend failures and empty RPC responses

This commit is contained in:
2026-05-27 21:32:32 +00:00
parent 9bac0a5f71
commit 78d7479b4a
6 changed files with 113 additions and 30 deletions
+23 -4
View File
@@ -977,9 +977,12 @@ export const fetchAppStoreTemplatesAction = appStoreStatePart.createAction(
async (statePartArg) => {
const request = new plugins.typedrequest.TypedRequest<any>('/typedrequest', 'getAppStoreTemplates');
const response = await request.fire({ identity: getIdentityForRequest() });
if (!response?.apps) {
throw new Error('The App Store returned an empty template response. Please retry.');
}
return {
...(statePartArg.getState() || { apps: [], upgradeableServices: [], upgradeOperations: [] }),
apps: response.apps || [],
apps: response.apps,
};
},
);
@@ -988,9 +991,12 @@ export const fetchUpgradeableAppStoreServicesAction = appStoreStatePart.createAc
async (statePartArg) => {
const request = new plugins.typedrequest.TypedRequest<any>('/typedrequest', 'getUpgradeableAppStoreServices');
const response = await request.fire({ identity: getIdentityForRequest() });
if (!response?.services) {
throw new Error('The App Store returned an empty upgradeable-services response. Please retry.');
}
return {
...(statePartArg.getState() || { apps: [], upgradeableServices: [], upgradeOperations: [] }),
upgradeableServices: response.services || [],
upgradeableServices: response.services,
};
},
);
@@ -999,9 +1005,12 @@ export const fetchAppStoreUpgradeOperationsAction = appStoreStatePart.createActi
async (statePartArg) => {
const request = new plugins.typedrequest.TypedRequest<any>('/typedrequest', 'getAppStoreUpgradeOperations');
const response = await request.fire({ identity: getIdentityForRequest() });
if (!response?.operations) {
throw new Error('The App Store returned an empty upgrade-operations response. Please retry.');
}
return {
...(statePartArg.getState() || { apps: [], upgradeableServices: [], upgradeOperations: [] }),
upgradeOperations: response.operations || [],
upgradeOperations: response.operations,
};
},
);
@@ -1027,7 +1036,7 @@ export const startAppStoreServiceUpgradeAction = appStoreStatePart.createAction<
export const getAppStoreConfig = async (appIdArg: string, versionArg: string) => {
const request = new plugins.typedrequest.TypedRequest<any>('/typedrequest', 'getAppStoreConfig');
return await request.fire({
const response = await request.fire({
identity: getIdentityForRequest(),
appId: appIdArg,
version: versionArg,
@@ -1035,6 +1044,10 @@ export const getAppStoreConfig = async (appIdArg: string, versionArg: string) =>
config: plugins.interfaces.appstore.IAppStoreVersionConfig;
appMeta: plugins.interfaces.appstore.IAppStoreAppMeta;
};
if (!response?.config || !response?.appMeta) {
throw new Error('The App Store returned an empty config response. Please retry.');
}
return response;
};
export const getAppStoreUpgradePreview = async (serviceIdArg: string, targetVersionArg?: string) => {
@@ -1044,6 +1057,9 @@ export const getAppStoreUpgradePreview = async (serviceIdArg: string, targetVers
serviceId: serviceIdArg,
targetVersion: targetVersionArg,
});
if (!response?.preview) {
throw new Error('The App Store returned an empty upgrade preview response. Please retry.');
}
return response.preview as IAppStoreUpgradePreview;
};
@@ -1053,5 +1069,8 @@ export const installAppStoreApp = async (installArg: plugins.interfaces.appstore
identity: getIdentityForRequest(),
install: installArg,
});
if (!response?.service) {
throw new Error('The App Store returned an empty install response. Please retry.');
}
return response.service as plugins.interfaces.data.IService;
};