boxerror: details is not a subobject
This commit is contained in:
22
src/apps.js
22
src/apps.js
@@ -1275,13 +1275,15 @@ async function scheduleTask(appId, installationState, taskId, auditSource) {
|
||||
debug(`scheduleTask: task ${taskId} of ${appId} completed. error: %o`, error);
|
||||
if (error?.code === tasks.ECRASHED || error?.code === tasks.ESTOPPED) { // if task crashed, update the error
|
||||
debug(`Apptask crashed/stopped: ${error.message}`);
|
||||
const boxError = new BoxError(BoxError.TASK_ERROR, error.message);
|
||||
boxError.details.crashed = error.code === tasks.ECRASHED;
|
||||
boxError.details.stopped = error.code === tasks.ESTOPPED;
|
||||
// see also apptask makeTaskError
|
||||
boxError.details.taskId = taskId;
|
||||
boxError.details.installationState = installationState;
|
||||
await safe(update(appId, { installationState: exports.ISTATE_ERROR, error: boxError.toPlainObject(), taskId: null }), { debug });
|
||||
const appError = {
|
||||
message: error.message,
|
||||
reason: BoxError.TASK_ERROR,
|
||||
crashed: error.code === tasks.ECRASHED,
|
||||
stopped: error.code === tasks.ESTOPPED,
|
||||
taskId,
|
||||
installationState
|
||||
};
|
||||
await safe(update(appId, { installationState: exports.ISTATE_ERROR, error: appError, taskId: null }), { debug });
|
||||
} else if (!(installationState === exports.ISTATE_PENDING_UNINSTALL && !error)) { // clear out taskId except for successful uninstall
|
||||
await safe(update(appId, { taskId: null }), { debug });
|
||||
}
|
||||
@@ -1297,7 +1299,7 @@ async function addTask(appId, installationState, task, auditSource) {
|
||||
assert.strictEqual(typeof auditSource, 'object');
|
||||
|
||||
const { args, values } = task;
|
||||
// TODO: match the SQL logic to match checkAppState. this means checking the error.details.installationState and installationState. Unfortunately, former is JSON right now
|
||||
// TODO: match the SQL logic to match checkAppState. this means checking the error.installationState and installationState. Unfortunately, former is JSON right now
|
||||
const requiredState = null; // 'requiredState' in task ? task.requiredState : exports.ISTATE_INSTALLED;
|
||||
const scheduleNow = 'scheduleNow' in task ? task.scheduleNow : true;
|
||||
const requireNullTaskId = 'requireNullTaskId' in task ? task.requireNullTaskId : true;
|
||||
@@ -1321,7 +1323,7 @@ function checkAppState(app, state) {
|
||||
|
||||
if (app.installationState === exports.ISTATE_ERROR) {
|
||||
// allow task to be called again if that was the errored task
|
||||
if (app.error.details.installationState === state) return null;
|
||||
if (app.error.installationState === state) return null;
|
||||
|
||||
// allow uninstall from any state
|
||||
if (state !== exports.ISTATE_PENDING_UNINSTALL && state !== exports.ISTATE_PENDING_RESTORE && state !== exports.ISTATE_PENDING_IMPORT) return new BoxError(BoxError.BAD_STATE, 'Not allowed in error state');
|
||||
@@ -2251,7 +2253,7 @@ async function repair(app, data, auditSource) {
|
||||
assert.strictEqual(typeof auditSource, 'object');
|
||||
|
||||
const appId = app.id;
|
||||
let errorState = (app.error && app.error.details.installationState) || exports.ISTATE_PENDING_CONFIGURE;
|
||||
let errorState = (app.error && app.error.installationState) || exports.ISTATE_PENDING_CONFIGURE;
|
||||
|
||||
const task = {
|
||||
args: {},
|
||||
|
||||
Reference in New Issue
Block a user