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:
2026-11-19 21:58:28 +02:00
co-authored by Claude Opus 5.5
parent 22d78ac81c
commit 3893fb91e0
9 changed files with 39 additions and 10 deletions
+12
View File
@@ -5,6 +5,18 @@ versions follow [Semantic Versioning](https://semver.org/).
## [Unreleased]
## [2.6.1] - 2026-11-19
### Fixed
- **Jobs → Failed answered 500 every time.** 2.6.0's status list had a `timed_out` that isn't a job
status (the database has `expired`), so Postgres refused the query. The list now matches the
JobStatus enum exactly (a test checks it), Failed shows failed and expired jobs, and a status or
product the database doesn't know is dropped or refused (400) instead of reaching it.
- **Searching alerts answered 500:** it searched the alert level (an enum) as text; it now matches
level names instead.
- Checked against Postgres: every jobs filter and the alerts and audit searches.
## [2.6.0] - 2026-11-19
### Added
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "events-hub-backend",
"version": "2.6.0",
"version": "2.6.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "events-hub-backend",
"version": "2.6.0",
"version": "2.6.1",
"hasInstallScript": true,
"dependencies": {
"@anthropic-ai/sdk": "^1.3.0",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "events-hub-backend",
"version": "2.6.0",
"version": "2.6.1",
"private": true,
"description": "Cross Events Hub — API for managing Cross Events installs, licences and heartbeats",
"main": "src/index.js",
+2 -1
View File
@@ -297,7 +297,8 @@ router.get('/events', wrap(async (req, res) => {
if (term) {
and.push({ OR: [
{ message: { contains: term, mode: 'insensitive' } },
{ level: { contains: term, mode: 'insensitive' } },
// `level` is an enum, which can't be searched as text: the levels whose name matches.
...(['info', 'warning', 'critical'].filter(l => l.includes(term.toLowerCase())).length ? [{ level: { in: ['info', 'warning', 'critical'].filter(l => l.includes(term.toLowerCase())) } }] : []),
{ install: { name: { contains: term, mode: 'insensitive' } } },
{ install: { url: { contains: term, mode: 'insensitive' } } },
] });
+7 -2
View File
@@ -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,
};
+11
View File
@@ -671,3 +671,14 @@ describe('the jobs list: every status, product, search and pages (2.6.0)', () =>
expect(pageOf({ pageSize: '100000' }).pageSize).toBe(200);
});
});
describe('the jobs list only asks for statuses the database knows (2.6.1)', () => {
test('JOB_STATUSES is exactly the JobStatus enum, and an old page\'s "timed_out" is dropped', async () => {
const schema = require('fs').readFileSync(require('path').join(__dirname, '..', 'prisma', 'schema.prisma'), 'utf8');
const block = /enum JobStatus \{([\s\S]*?)\}/.exec(schema)[1];
const values = block.split(/\r?\n/).map(l => l.replace(/\/\/.*$/, '').trim()).filter(Boolean);
expect([...jobs.JOB_STATUSES].sort()).toEqual([...values].sort());
expect(await jobs.listWhere({ status: 'failed,timed_out' })).toEqual({ AND: [{ status: { in: ['failed'] } }] });
expect(await jobs.listWhere({ status: 'failed,expired' })).toEqual({ AND: [{ status: { in: ['failed', 'expired'] } }] });
});
});
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "events-hub-frontend",
"version": "2.6.0",
"version": "2.6.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "events-hub-frontend",
"version": "2.6.0",
"version": "2.6.1",
"dependencies": {
"lucide-react": "^0.536.0",
"next": "^15.5.24",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "events-hub-frontend",
"version": "2.6.0",
"version": "2.6.1",
"private": true,
"scripts": {
"dev": "next dev -p 3200",
+1 -1
View File
@@ -11,7 +11,7 @@ const FILTERS = [
{ key: "", label: "All" },
{ key: "upcoming", label: "Planned and running" },
{ key: "succeeded", label: "Succeeded" },
{ key: "failed,timed_out", label: "Failed" },
{ key: "failed,expired", label: "Failed" },
{ key: "rolled_back", label: "Rolled back" },
{ key: "missed", label: "Missed" },
{ key: "refused", label: "Refused" },