Hub 2.3.3: refuse server settings the apps can't start with
TRUST_PROXY=TRUE made an Events install build for minutes, then crash at startup. Saving a server's configuration now refuses it, and installs and updates are refused (CONFIG_INVALID) while an older saved configuration has one. Contracts 1.6.0 vendored (agent.checkEnvValue / invalidValues). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -40,4 +40,13 @@ async function missingFor(product, version, serverValues, defaults) {
|
||||
return { server: agent.missingRequired(template, 'server', serverValues), defaults: agent.missingRequired(template, 'defaults', defaults) };
|
||||
}
|
||||
|
||||
module.exports = { envTemplate, missingFor, _cache: cache, getSettings };
|
||||
/**
|
||||
* Values the apps can't start with, as sentences (e.g. TRUST_PROXY=TRUE, which crashed the Events
|
||||
* backend after an install's build). Saving a configuration checks them too, but configurations
|
||||
* saved before Hub 2.3.3 weren't checked.
|
||||
*/
|
||||
function invalidFor(serverValues, defaults) {
|
||||
return [...Object.values(agent.invalidValues(serverValues || {})), ...Object.values(agent.invalidValues(defaults || {}))];
|
||||
}
|
||||
|
||||
module.exports = { envTemplate, missingFor, invalidFor, _cache: cache, getSettings };
|
||||
|
||||
@@ -22,7 +22,7 @@ const { generateLicence } = require('./licences');
|
||||
const { unmetRequirementsFor } = require('./releases');
|
||||
const { compareVersions } = require('./alerts');
|
||||
const servers = require('./servers');
|
||||
const { missingFor } = require('./envTemplates');
|
||||
const { missingFor, invalidFor } = require('./envTemplates');
|
||||
|
||||
const MIN = 60 * 1000;
|
||||
const HOUR = 60 * MIN;
|
||||
@@ -384,6 +384,8 @@ async function preflight(server, product, version, now) {
|
||||
if (missing.server.length) parts.push(`${server.name}'s configuration needs ${missing.server.join(', ')}`);
|
||||
if (missing.defaults.length) parts.push(`Install defaults need ${missing.defaults.join(', ')}`);
|
||||
if (parts.length) throw fail(409, 'CONFIG_MISSING', `${parts.join('; ')} (Servers → ${server.name} → Configuration).`);
|
||||
const invalid = invalidFor(servers.serverConfig(server), await servers.installDefaults());
|
||||
if (invalid.length) throw fail(409, 'CONFIG_INVALID', `${server.name}'s configuration: ${invalid.join(' ')} (Servers → ${server.name} → Configuration).`);
|
||||
}
|
||||
|
||||
/** Products the Hub can install so far (Accounts from Hub 2.3.0, docs/ACCOUNTS-1.0-PLAN.md §9). */
|
||||
@@ -519,6 +521,8 @@ async function scheduleUpdate({ deploymentIds, version, at, emergency = false, r
|
||||
}
|
||||
const missing = await missingFor(product, release.version, servers.serverConfig(d.server), await servers.installDefaults());
|
||||
if (missing.server.length || missing.defaults.length) throw fail(409, 'CONFIG_MISSING', `${d.shortName}: set ${[...missing.server, ...missing.defaults].join(', ')} first.`);
|
||||
const invalid = invalidFor(servers.serverConfig(d.server), await servers.installDefaults());
|
||||
if (invalid.length) throw fail(409, 'CONFIG_INVALID', `${d.shortName}: fix ${d.server.name}'s configuration first. ${invalid.join(' ')}`);
|
||||
warnings.push(...scheduleWarnings(when, d));
|
||||
}
|
||||
const batchId = deployments.length > 1 ? servers.newId('batch') : null;
|
||||
|
||||
Reference in New Issue
Block a user