Hub 2.6.1: the Failed jobs filter and alert search no longer answer 500
The status list had timed_out, which isn't a JobStatus (the enum has expired), and alert search used contains on the EventLevel enum: Postgres refused both queries. JOB_STATUSES now matches the enum (tested against schema.prisma); Failed = failed,expired; unknown products refused; level matched by name. All list queries checked on Postgres. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -600,7 +600,10 @@ async function lookForUnlinked(install, now = new Date()) {
|
||||
}
|
||||
}
|
||||
|
||||
const JOB_STATUSES = ['queued', 'scheduled', 'delivered', 'succeeded', 'failed', 'rolled_back', 'refused', 'missed', 'cancelled', 'timed_out'];
|
||||
// Exactly the JobStatus enum (prisma/schema.prisma; a test checks it): a value Postgres doesn't
|
||||
// know fails the whole query. 2.6.1: 2.6.0 listed a "timed_out" that doesn't exist, so the Failed
|
||||
// filter answered 500 every time. Unknown values from a request are dropped.
|
||||
const JOB_STATUSES = ['scheduled', 'queued', 'delivered', 'succeeded', 'failed', 'rolled_back', 'refused', 'expired', 'missed', 'cancelled'];
|
||||
|
||||
/** The jobs list's filters (Hub 2.6.0, GET /api/admin/jobs). */
|
||||
async function listWhere(q = {}) {
|
||||
@@ -616,6 +619,8 @@ async function listWhere(q = {}) {
|
||||
if (q.deploymentId) and.push({ deploymentId: String(q.deploymentId) });
|
||||
// By product or church: the matching installs first, then their jobs.
|
||||
const term = searchTerm(q.q);
|
||||
// Products are an enum too: an unknown one is refused, not sent to the database.
|
||||
if (q.product && !PRODUCT_NAMES[String(q.product)]) throw fail(400, 'BAD_REQUEST', 'Unknown product.');
|
||||
if (q.product || term) {
|
||||
const dWhere = { AND: [
|
||||
...(q.product ? [{ product: String(q.product) }] : []),
|
||||
@@ -947,6 +952,6 @@ async function seedDemo({ deploymentId, profile, confirm }, admin, now = new Dat
|
||||
module.exports = {
|
||||
WINDOW_MIN, SCHEDULE_MIN_HOURS, EMERGENCY_MIN_MINUTES, setDemo, seedDemo,
|
||||
makeJob, signedJob, jobConfig, poll, receiveReport, finish, tick, advanceBatch,
|
||||
linkFromStatus, listWhere, lookForUnlinked, newInstall, proxyDone, scheduleUpdate, cancelJob, scheduleUninstall, neverInstalled, removeFailedInstall, receiveExport, linkDeployment, scheduleAdopt, queueCentralCheck, runNow,
|
||||
JOB_STATUSES, linkFromStatus, listWhere, lookForUnlinked, newInstall, proxyDone, scheduleUpdate, cancelJob, scheduleUninstall, neverInstalled, removeFailedInstall, receiveExport, linkDeployment, scheduleAdopt, queueCentralCheck, runNow,
|
||||
fastPanelText, jobReportText, scheduleWarnings, requireTotp, agentOnline, siteAdminEmail,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user