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:
@@ -5,6 +5,18 @@ versions follow [Semantic Versioning](https://semver.org/).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [2.3.3] - 2026-11-19
|
||||
|
||||
### Fixed
|
||||
|
||||
- **A server setting the apps can't start with is refused up front.** With `TRUST_PROXY=TRUE` in
|
||||
a server's configuration, an Events install built for minutes and then failed: the backend
|
||||
crashed at startup (`invalid IP address: TRUE`) and the install was removed. Saving a server's
|
||||
configuration now refuses such a value, saying what to use instead (`loopback` behind frp), and
|
||||
installs and updates are refused (`CONFIG_INVALID`) while a configuration saved before this
|
||||
still has one. The rules are `agent.checkEnvValue` in `@crosscode/contracts` 1.6.0 (now
|
||||
vendored); the crosscode script checks again on the server.
|
||||
|
||||
## [2.3.2] - 2026-11-19
|
||||
|
||||
### Fixed
|
||||
|
||||
Generated
+6
-6
@@ -1,16 +1,16 @@
|
||||
{
|
||||
"name": "events-hub-backend",
|
||||
"version": "2.3.2",
|
||||
"version": "2.3.3",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "events-hub-backend",
|
||||
"version": "2.3.2",
|
||||
"version": "2.3.3",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"@anthropic-ai/sdk": "^1.3.0",
|
||||
"@crosscode/contracts": "file:vendor/crosscode-contracts-1.5.0.tgz",
|
||||
"@crosscode/contracts": "file:vendor/crosscode-contracts-1.6.0.tgz",
|
||||
"@prisma/adapter-pg": "^7.10.1",
|
||||
"@prisma/client": "^7.10.1",
|
||||
"bcryptjs": "^2.4.3",
|
||||
@@ -609,9 +609,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@crosscode/contracts": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "file:vendor/crosscode-contracts-1.5.0.tgz",
|
||||
"integrity": "sha512-J3t9tUjPBfyS2UL2wKi49Bc7Ci/Qfy3V6HRj4Z25mNDs4bagi3LqsDwlsxT+Tq9Gxo/GJrIkn73KpDdAGZ2aSw==",
|
||||
"version": "1.6.0",
|
||||
"resolved": "file:vendor/crosscode-contracts-1.6.0.tgz",
|
||||
"integrity": "sha512-uAgoeo0eVUrQtklucztwXxRaawf33ITGqvob7i1C4BcgEkm4hIKbOHWp1qZxW3xT0vkZPfjoeLKtCHp8j1/rSg==",
|
||||
"license": "UNLICENSED",
|
||||
"dependencies": {
|
||||
"zod": "^4.6.7"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "events-hub-backend",
|
||||
"version": "2.3.2",
|
||||
"version": "2.3.3",
|
||||
"private": true,
|
||||
"description": "Cross Events Hub — API for managing Cross Events installs, licences and heartbeats",
|
||||
"main": "src/index.js",
|
||||
@@ -20,7 +20,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@anthropic-ai/sdk": "^1.3.0",
|
||||
"@crosscode/contracts": "file:vendor/crosscode-contracts-1.5.0.tgz",
|
||||
"@crosscode/contracts": "file:vendor/crosscode-contracts-1.6.0.tgz",
|
||||
"@prisma/adapter-pg": "^7.10.1",
|
||||
"@prisma/client": "^7.10.1",
|
||||
"bcryptjs": "^2.4.3",
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
const express = require('express');
|
||||
const { agent } = require('@crosscode/contracts');
|
||||
const prisma = require('../config/db');
|
||||
const { protect } = require('../middleware/auth');
|
||||
const { audit } = require('../utils/audit');
|
||||
@@ -119,6 +120,9 @@ router.put('/servers/:id/config', wrap(async (req, res) => {
|
||||
const current = servers.serverConfig(s);
|
||||
const next = {};
|
||||
for (const [k, v] of Object.entries(req.body?.values || {})) next[k] = v === MASK ? current[k] : v;
|
||||
// A value the apps can't start with (TRUST_PROXY=TRUE crashed Events after a whole build).
|
||||
const invalid = agent.invalidValues(next);
|
||||
if (Object.keys(invalid).length) throw Object.assign(bad(Object.values(invalid).join(' ')), { code: 'CONFIG_INVALID' });
|
||||
const saved = await servers.setServerConfig(s.id, next);
|
||||
await audit(req, 'server_config_changed', s.id, { keys: Object.keys(saved) });
|
||||
res.json({ config: masked(saved) });
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -118,6 +118,16 @@ describe('jobs', () => {
|
||||
expect((await jobs.poll(server, { agentApiVersion: 1, agentVersion: '1.0.0', mode: 'church', runningJobId: null }, NOW)).jobs).toEqual([]);
|
||||
});
|
||||
|
||||
test('a new install is refused while a server setting is one the apps can\'t start with (TRUST_PROXY=TRUE)', async () => {
|
||||
const { server } = await joinServer();
|
||||
// Saved before Hub 2.3.3, which refuses it on save.
|
||||
await servers.setServerConfig(server.id, { TRUST_PROXY: 'TRUE' });
|
||||
await expect(jobs.newInstall({ customerId: 'cust-1', serverId: server.id, shortName: 'hope', domain: 'events.hope.co.za' }, admin, NOW))
|
||||
.rejects.toMatchObject({ code: 'CONFIG_INVALID', message: expect.stringContaining('loopback') });
|
||||
await servers.setServerConfig(server.id, { TRUST_PROXY: 'loopback' });
|
||||
await expect(jobs.newInstall({ customerId: 'cust-1', serverId: server.id, shortName: 'hope', domain: 'events.hope.co.za' }, admin, NOW)).resolves.toBeTruthy();
|
||||
});
|
||||
|
||||
test('a new install is refused while required server settings are missing, or the agent is offline', async () => {
|
||||
const { server } = await joinServer();
|
||||
await expect(jobs.newInstall({ customerId: 'cust-1', serverId: server.id, shortName: 'hope', domain: 'events.hope.co.za' }, admin, NOW)).rejects.toMatchObject({ code: 'CONFIG_MISSING', message: expect.stringContaining('TRUST_PROXY') });
|
||||
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
+2
-1
@@ -413,7 +413,8 @@ or FASTPANEL: agents reach the Hub on its normal address.
|
||||
every FASTPANEL site still answers after restarting frps), then Servers → Add server →
|
||||
Central, and run the command it shows as root.
|
||||
5. **Each church server:** Add server → Church, run the command, then on its page set its
|
||||
configuration: `TRUST_PROXY` (`loopback` behind frp) and the database (`DB_HOST`, `DB_PORT`,
|
||||
configuration: `TRUST_PROXY` (`loopback` behind frp, lowercase: the Hub refuses a value the apps
|
||||
can't start with, such as `TRUE`) and the database (`DB_HOST`, `DB_PORT`,
|
||||
`DB_ADMIN_URL`, or nothing for the local PostgreSQL).
|
||||
6. **Existing installs:** Servers → Installs → Link existing (server, folder name, its two ports).
|
||||
Installs still on 2.1.x from `hope-events` then get a **Move onto the monorepo** (an `adopt` job,
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "events-hub-frontend",
|
||||
"version": "2.3.2",
|
||||
"version": "2.3.3",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "events-hub-frontend",
|
||||
"version": "2.3.2",
|
||||
"version": "2.3.3",
|
||||
"dependencies": {
|
||||
"lucide-react": "^0.536.0",
|
||||
"next": "^15.5.24",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "events-hub-frontend",
|
||||
"version": "2.3.2",
|
||||
"version": "2.3.3",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev -p 3200",
|
||||
|
||||
@@ -23,7 +23,7 @@ type Detail = {
|
||||
|
||||
/** The settings a church server's jobs need (§5); others can be added. */
|
||||
const SUGGESTED: { key: string; hint: string }[] = [
|
||||
{ key: "TRUST_PROXY", hint: "Behind frp: loopback" },
|
||||
{ key: "TRUST_PROXY", hint: "Behind frp: loopback (lowercase; checked when saved)" },
|
||||
{ key: "DB_HOST", hint: "The PostgreSQL server the sites use (default localhost)" },
|
||||
{ key: "DB_PORT", hint: "Default 5432" },
|
||||
{ key: "DB_ADMIN_URL", hint: "postgresql://admin:…@host/postgres: may create databases and roles. Blank: the local PostgreSQL via sudo -u postgres" },
|
||||
|
||||
Reference in New Issue
Block a user