Merge pull request #734 from PicPeak/fix/event-create-nan-and-bool-render

fix: event creation 500s on PostgreSQL (NaN slideshow seed) + stray "0" boolean renders
This commit is contained in:
Paul Nothaft
2026-07-03 11:46:58 +02:00
committed by GitHub
4 changed files with 81 additions and 7 deletions
+8 -1
View File
@@ -27,6 +27,7 @@ const { validateFileType } = require('../utils/fileSecurityUtils');
const { requireEventOwnership } = require('../middleware/ownership');
const { requireFeatureFlag } = require('../middleware/requireFeatureFlag');
const { getAppSetting } = require('../utils/appSettings');
const { clampIntOrUndefined } = require('../utils/numericHelpers');
const { getFrontendBaseUrl } = require('../utils/frontendUrl');
const downloadZipService = require('../services/downloadZipService');
@@ -682,7 +683,13 @@ router.post('/', adminAuth, requirePermission('events.create'), [
let slideshowSeed = {};
if (await hasColumnCached('events', 'show_interval_ms')) {
try {
const intP = (v, min, max) => (Number.isFinite(+v) ? Math.min(max, Math.max(min, parseInt(v, 10))) : undefined);
// parseInt-first: the previous `Number.isFinite(+v)` pre-check let
// NaN through for null/''/true (+null is 0, parseInt(null) is NaN),
// producing show_interval_ms=NaN in the INSERT — PG rejects that
// with "invalid input syntax for type integer" while SQLite
// silently stores NULL, so event creation 500'd on PG whenever the
// slideshow app_settings rows were absent.
const intP = (v, min, max) => clampIntOrUndefined(v, min, max);
const oneOf = (v, allowed) => (allowed.includes(v) ? v : undefined);
const i = intP(await getAppSetting('slideshow_interval_ms', undefined), 1000, 120000);
const tr = oneOf(await getAppSetting('slideshow_transition', undefined), SLIDESHOW_TRANSITIONS);