mirror of https://github.com/openclaw/openclaw.git
fix(gateway): catch invalid cron session targets
This commit is contained in:
parent
eb0f367e00
commit
42bc411c46
|
|
@ -245,20 +245,16 @@ export const cronHandlers: GatewayRequestHandlers = {
|
|||
);
|
||||
return;
|
||||
}
|
||||
const result = await context.cron.enqueueRun(jobId, p.mode ?? "force");
|
||||
if (
|
||||
result.ok &&
|
||||
"ran" in result &&
|
||||
!result.ran &&
|
||||
"reason" in result &&
|
||||
result.reason === "unsupported-spec"
|
||||
) {
|
||||
respond(
|
||||
false,
|
||||
undefined,
|
||||
errorShape(ErrorCodes.INVALID_REQUEST, "invalid cron sessionTarget session id"),
|
||||
);
|
||||
return;
|
||||
let result: Awaited<ReturnType<typeof context.cron.enqueueRun>>;
|
||||
try {
|
||||
result = await context.cron.enqueueRun(jobId, p.mode ?? "force");
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
if (message === "invalid cron sessionTarget session id") {
|
||||
respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, message));
|
||||
return;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
respond(true, result, undefined);
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue