Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(dashboard): warn of a backend switch by where the next boot connects
Yudhi Armyndharisc716150a8493
diff --git a/dashboard/src/pages/Infrastructure.test.ts b/dashboard/src/pages/Infrastructure.test.tsindex 85460631b..f298cd841 100644--- a/dashboard/src/pages/Infrastructure.test.ts+++ b/dashboard/src/pages/Infrastructure.test.ts@@ -15,7 +15,15 @@ import { createElement } from 'react';import { QueryClient, QueryClientProvider } from '@tanstack/react-query';import type { InfraStatus, SavedConfig, Engine } from '../services/api';import type { installJsdomGlobals as installJsdomGlobalsFn } from '../test-helpers/jsdom.ts';-import { EXPECTED_MODE, FILE_STATES, PIN_STATES } from '../../../test/fixtures/builtin-mode-cases.ts';+import {+ EXPECTED_MODE,+ FILE_STATES,+ PIN_STATES,+ SERVICES,+ pinnedHost,+ type PinState,+ type ServiceName,+} from '../../../test/fixtures/builtin-mode-cases.ts';// ── Fixtures + fetch stub ────────────────────────────────────────────────────@@ -741,7 +749,7 @@ const RUNNING_BUNDLED: InfraStatus = {...INFRA_STATUS,database: { connected: true, type: 'postgres', host: 'postgres', builtIn: true },redis: { enabled: true, connected: true, host: 'redis', port: 6379, builtIn: true },- storage: { type: 's3', bucket: 'openwa', builtIn: true, s3Available: true },+ storage: { type: 's3', bucket: 'openwa', endpoint: 'http://minio:9000', builtIn: true, s3Available: true },};const SAVED_EXTERNAL: SavedConfig = {...SAVED_CONFIG,@@ -1040,6 +1048,236 @@ test('the built-in notes are hidden while a save is in flight and back once it sawait waitFor(() => assert.equal(screen.queryAllByText(PENDING_BUILT_IN_NOTE).length, 2));});+// ── The data-backend warning compares where the next boot connects with where the server connects now ──+// Whether a bundled container runs right now says nothing about that: a stopped or removed one is started again+// on the same host and the same named volume, so nothing starts empty.++const RUNNING_STOPPED: InfraStatus = {+ ...INFRA_STATUS,+ database: { connected: false, type: 'postgres', host: 'postgres', builtIn: false },+ storage: { type: 's3', bucket: 'openwa', endpoint: 'http://minio:9000', builtIn: false, s3Available: false },+};+const SAVED_BUNDLED_HOSTS: SavedConfig = {+ ...SAVED_CONFIG,+ database: { ...SAVED_CONFIG.database, host: 'postgres', builtIn: true, builtInSet: true },+ storage: {+ ...SAVED_CONFIG.storage,+ type: 's3',+ builtIn: true,+ builtInSet: true,+ s3Bucket: 'openwa',+ s3Endpoint: 'http://minio:9000',+ },+};++test('a saved built-in database and storage whose containers are stopped warn of no switch', async () => {+ const { screen, waitFor, fireEvent, within } = rtl;+ resetFetchCalls();+ overrides = { status: RUNNING_STOPPED, saved: SAVED_BUNDLED_HOSTS, saveProfiles: ['postgres', 'minio'] };+ const { container } = renderInfrastructure();++ await screen.findByText('Database Configuration');+ await awaitSeeded(container);+ fireEvent.click(toggleInput(container, 'Headless Mode'));+ fireEvent.click(screen.getByRole('button', { name: 'Save Configuration' }));++ const dialog = await screen.findByRole('dialog');+ assert.equal(within(dialog).queryByText(DB_SWITCH_WARNING, { exact: false }) === null, true, 'database warning');+ assert.equal(within(dialog).queryByText(STORAGE_WARNING, { exact: false }) === null, true, 'storage warning');+ fireEvent.click(within(dialog).getByRole('button', { name: 'Restart Now' }));+ await waitFor(() => assert.ok(findFetchCall('POST', '/api/infra/restart'), 'expected the restart POST'));+ assert.deepEqual(findFetchCall('POST', '/api/infra/restart')!.body, {+ profiles: ['postgres', 'minio'],+ profilesToRemove: [],+ });+});++test('moving off a stopped bundled database and storage still warns of the switch', async () => {+ const { screen, fireEvent, within } = rtl;+ resetFetchCalls();+ overrides = { status: RUNNING_STOPPED, saved: SAVED_BUNDLED_HOSTS };+ const { container } = renderInfrastructure();++ await screen.findByText('Database Configuration');+ await awaitSeeded(container);+ fireEvent.click(toggleInput(container, 'Use Built-in PostgreSQL Container'));+ fireEvent.change(fieldInput(container, 'Host'), { target: { value: 'db.new.example' } });+ fireEvent.click(toggleInput(container, 'Use Built-in MinIO Container'));+ fireEvent.change(fieldInput(container, 'Custom Endpoint (optional)'), {+ target: { value: 'https://s3.new.example' },+ });+ fireEvent.click(screen.getByRole('button', { name: 'Save Configuration' }));++ const dialog = await screen.findByRole('dialog');+ within(dialog).getByText(DB_SWITCH_WARNING, { exact: false });+ within(dialog).getByText(STORAGE_WARNING, { exact: false });+});++// An external store moved to another bucket or endpoint leaves the media behind just like a backend change.+test('repointing external S3 storage to another bucket warns that the media stays behind', async () => {+ const { screen, fireEvent, within } = rtl;+ resetFetchCalls();+ overrides = {+ status: {+ ...INFRA_STATUS,+ storage: { type: 's3', bucket: 'media', endpoint: 'https://s3.example', builtIn: false, s3Available: true },+ },+ saved: {+ ...SAVED_CONFIG,+ storage: { ...SAVED_CONFIG.storage, type: 's3', s3Bucket: 'media', s3Endpoint: 'https://s3.example' },+ },+ };+ const { container } = renderInfrastructure();++ await screen.findByText('Database Configuration');+ await awaitSeeded(container);+ fireEvent.change(fieldInput(container, 'Bucket Name'), { target: { value: 'media-2' } });+ fireEvent.click(screen.getByRole('button', { name: 'Save Configuration' }));++ within(await screen.findByRole('dialog')).getByText(STORAGE_WARNING, { exact: false });+});++// The gateway reports no bucket when none is set, and the store then uses its default one.+test('S3 storage on the default bucket warns of nothing on an unrelated save', async () => {+ const { screen, fireEvent, within } = rtl;+ resetFetchCalls();+ overrides = {+ status: {+ ...INFRA_STATUS,+ storage: { type: 's3', endpoint: 'https://s3.example', builtIn: false, s3Available: true },+ },+ saved: { ...SAVED_CONFIG, storage: { ...SAVED_CONFIG.storage, type: 's3', s3Endpoint: 'https://s3.example' } },+ };+ const { container } = renderInfrastructure();++ await screen.findByText('Database Configuration');+ await awaitSeeded(container);+ fireEvent.click(toggleInput(container, 'Headless Mode'));+ fireEvent.click(screen.getByRole('button', { name: 'Save Configuration' }));++ const dialog = await screen.findByRole('dialog');+ assert.equal(within(dialog).queryByText(STORAGE_WARNING, { exact: false }) === null, true, 'storage warning');+});++test('pointing an external PostgreSQL at another database name warns of the switch', async () => {+ const { screen, fireEvent, within } = rtl;+ resetFetchCalls();+ const { container } = renderInfrastructure();++ await screen.findByText('Database Configuration');+ await awaitConfigHydrated(container);+ fireEvent.change(fieldInput(container, 'Database Name'), { target: { value: 'openwa_other' } });+ fireEvent.click(screen.getByRole('button', { name: 'Save Configuration' }));++ within(await screen.findByRole('dialog')).getByText(DB_SWITCH_WARNING, { exact: false });+});++// A pinned type outranks the radio the same way a pinned host outranks the toggle.+test('changing a database or storage type the environment pins warns of no switch', async () => {+ const { screen, fireEvent, within } = rtl;+ resetFetchCalls();+ overrides = {+ status: {+ ...INFRA_STATUS,+ storage: { type: 's3', bucket: 'media', endpoint: 'https://s3.example', builtIn: false, s3Available: true },+ envPinned: ['DATABASE_TYPE', 'STORAGE_TYPE'],+ },+ saved: {+ ...SAVED_CONFIG,+ storage: { ...SAVED_CONFIG.storage, type: 's3', s3Bucket: 'media', s3Endpoint: 'https://s3.example' },+ },+ };+ const { container } = renderInfrastructure();++ await screen.findByText('Database Configuration');+ await awaitSeeded(container);+ fireEvent.click(container.querySelectorAll<HTMLInputElement>('input[name="dbType"]')[0]);+ fireEvent.click(container.querySelectorAll<HTMLInputElement>('input[name="storageType"]')[0]);+ fireEvent.click(screen.getByRole('button', { name: 'Save Configuration' }));++ const dialog = await screen.findByRole('dialog');+ assert.equal(within(dialog).queryByText(DB_SWITCH_WARNING, { exact: false }) === null, true, 'database warning');+ assert.equal(within(dialog).queryByText(STORAGE_WARNING, { exact: false }) === null, true, 'storage warning');+});++// A pinned external host outranks the toggle, so turning Use Built-in on moves nothing.+test('turning Use Built-in on under a pinned external host warns of no switch', async () => {+ const { screen, fireEvent, within } = rtl;+ resetFetchCalls();+ overrides = {+ status: {+ ...INFRA_STATUS,+ database: { connected: true, type: 'postgres', host: 'db.external.example', builtIn: false },+ storage: { type: 's3', bucket: 'openwa', endpoint: 'https://s3.example', builtIn: false, s3Available: true },+ envPinned: ['DATABASE_HOST', 'S3_ENDPOINT'],+ },+ saved: {+ ...SAVED_CONFIG,+ database: { ...SAVED_CONFIG.database, host: 'db.external.example', builtIn: false, builtInSet: false },+ storage: {+ ...SAVED_CONFIG.storage,+ type: 's3',+ builtIn: false,+ builtInSet: false,+ s3Bucket: 'openwa',+ s3Endpoint: 'https://s3.example',+ },+ },+ };+ const { container } = renderInfrastructure();++ await screen.findByText('Database Configuration');+ await awaitSeeded(container);+ fireEvent.click(toggleInput(container, 'Use Built-in PostgreSQL Container'));+ fireEvent.click(toggleInput(container, 'Use Built-in MinIO Container'));+ fireEvent.click(screen.getByRole('button', { name: 'Save Configuration' }));++ const dialog = await screen.findByRole('dialog');+ assert.equal(within(dialog).queryByText(DB_SWITCH_WARNING, { exact: false }) === null, true, 'database warning');+ assert.equal(within(dialog).queryByText(STORAGE_WARNING, { exact: false }) === null, true, 'storage warning');+});++// The host is compared as the save writes it, trimmed and with the default for an empty field.+test('a host typed with spaces around it is no switch', async () => {+ const { screen, fireEvent, within } = rtl;+ resetFetchCalls();+ const { container } = renderInfrastructure();++ await screen.findByText('Database Configuration');+ await awaitConfigHydrated(container);+ fireEvent.change(fieldInput(container, 'Host'), { target: { value: ' shared-db-host ' } });+ fireEvent.click(screen.getByRole('button', { name: 'Save Configuration' }));++ const dialog = await screen.findByRole('dialog');+ assert.equal(within(dialog).queryByText(DB_SWITCH_WARNING, { exact: false }) === null, true, 'database warning');+});++// A built-in choice saves the bundled port and database name, so values typed in the hidden external fields are+// not where the next boot connects.+test('external values typed and then hidden by a running built-in database are no switch', async () => {+ const { screen, fireEvent, within } = rtl;+ resetFetchCalls();+ overrides = {+ status: RUNNING_BUNDLED,+ saved: {+ ...SAVED_CONFIG,+ database: { ...SAVED_CONFIG.database, host: 'postgres', builtIn: true, builtInSet: true },+ },+ };+ const { container } = renderInfrastructure();++ await screen.findByText('Database Configuration');+ await awaitSeeded(container);+ fireEvent.click(toggleInput(container, 'Use Built-in PostgreSQL Container'));+ fireEvent.change(fieldInput(container, 'Port'), { target: { value: '6000' } });+ fireEvent.change(fieldInput(container, 'Database Name'), { target: { value: 'other' } });+ fireEvent.click(toggleInput(container, 'Use Built-in PostgreSQL Container'));+ fireEvent.click(screen.getByRole('button', { name: 'Save Configuration' }));++ const dialog = await screen.findByRole('dialog');+ assert.equal(within(dialog).queryByText(DB_SWITCH_WARNING, { exact: false }) === null, true, 'database warning');+});+// SQLite runs and bundled PostgreSQL is saved: the database note names the type change, and a running// "external" flag would be a claim about a database that is not running.test('no built-in note beside a pending database type', async () => {@@ -1062,18 +1300,42 @@ test('no built-in note beside a pending database type', async () => {// ── One rule for every saved and pinned state ────────────────────────────────// GET /config answers the saved built-in mode (builtIn, builtInSet) from the file and the environment pins; the// table in test/fixtures/builtin-mode-cases.ts is what the controller specs assert it against. Here every one of-// those answers, with the service running bundled and running external, is rendered into the page. The page-// follows the saved mode when builtInSet says one is saved and what runs otherwise, so the toggle, the pending-// note under it, the data-backend warning after a save and the flag the save sends must all come from the same-// shown mode. The three services are given different combinations in each render, so one reading another's-// flag or answer shows up.-+// those answers is rendered into the page with each state /status can report beside it: the bundled container+// running, an external service, or the bundled host the server dials with its container stopped. A pinned+// bundled host runs the container or finds it stopped, and a pinned external host runs neither. The page follows+// the saved mode when builtInSet says one is saved and what runs otherwise, so the toggle, the pending note under+// it and the flag the save sends come from the same shown mode, and the data-backend warning from where the next+// boot connects against where the server connects now. The three services are given different combinations in+// each render, so one reading another's flag or answer shows up.++type RunState = 'bundled' | 'external' | 'stopped';+const RUN_STATES: Record<PinState, RunState[]> = {+ none: ['bundled', 'external', 'stopped'],+ bundled: ['bundled', 'stopped'],+ external: ['external'],+};const COMBOS = FILE_STATES.flatMap(file =>- PIN_STATES.flatMap(pin => [true, false].map(running => ({ file, pin, running, mode: EXPECTED_MODE[file][pin] }))),+ PIN_STATES.flatMap(pin => RUN_STATES[pin].map(run => ({ file, pin, run, mode: EXPECTED_MODE[file][pin] }))),);type Combo = (typeof COMBOS)[number];-const comboLabel = (c: Combo) => `${c.file}/${c.pin}/${c.running ? 'bundled' : 'external'}`;-const shownMode = (c: Combo) => (c.mode.builtInSet ? c.mode.builtIn : c.running);+const comboLabel = (c: Combo) => `${c.file}/${c.pin}/${c.run}`;+const containerRuns = (c: Combo) => c.run === 'bundled';+const shownMode = (c: Combo) => (c.mode.builtInSet ? c.mode.builtIn : containerRuns(c));+// The host the server connects to now: the bundled one unless an external service runs.+const statusHost = (service: ServiceName, c: Combo) =>+ c.run === 'external' ? SERVICES[service].externalHost : SERVICES[service].bundledHost;+// The host the saved config names: a pin decides it; otherwise a file that holds the bundled host names that one,+// and any other an external service.+const savedHost = (service: ServiceName, c: Combo) =>+ pinnedHost(service, c.pin) ??+ (c.file === 'bundled-host' || c.file === 'saved-bundled'+ ? SERVICES[service].bundledHost+ : SERVICES[service].externalHost);+// The next boot connects to a pinned host whatever the toggle says, to the bundled one for a built-in choice, and+// to the saved one otherwise.+const nextHost = (service: ServiceName, c: Combo) =>+ c.pin === 'none' && shownMode(c) ? SERVICES[service].bundledHost : savedHost(service, c);+const bucketFor = (service: ServiceName, host: string) => (host === SERVICES[service].bundledHost ? 'openwa' : 'media');/** The notes rendered right under a toggle row, in order. */function notesUnderToggle(container: HTMLElement, labelText: string): string[] {@@ -1111,9 +1373,26 @@ COMBOS.forEach((_, i) => {overrides = {status: {...INFRA_STATUS,- database: { connected: true, type: 'postgres', host: 'shared-db-host', builtIn: database.running },- redis: { enabled: true, connected: true, host: 'redis.internal', port: 6379, builtIn: redis.running },- storage: { type: 's3', bucket: 'media', builtIn: storage.running, s3Available: true },+ database: {+ connected: true,+ type: 'postgres',+ host: statusHost('database', database),+ builtIn: containerRuns(database),+ },+ redis: {+ enabled: true,+ connected: true,+ host: statusHost('redis', redis),+ port: 6379,+ builtIn: containerRuns(redis),+ },+ storage: {+ type: 's3',+ bucket: bucketFor('storage', statusHost('storage', storage)),+ endpoint: statusHost('storage', storage),+ builtIn: containerRuns(storage),+ s3Available: true,+ },// A pinned host is reported, so the page can say why its toggle cannot take effect.envPinned: [database.pin !== 'none' && 'DATABASE_HOST',@@ -1123,9 +1402,15 @@ COMBOS.forEach((_, i) => {},saved: {...SAVED_CONFIG,- database: { ...SAVED_CONFIG.database, ...database.mode },- redis: { enabled: true, host: 'redis.internal', port: '6379', passwordSet: false, ...redis.mode },- storage: { ...SAVED_CONFIG.storage, type: 's3', ...storage.mode },+ database: { ...SAVED_CONFIG.database, host: savedHost('database', database), ...database.mode },+ redis: { enabled: true, host: savedHost('redis', redis), port: '6379', passwordSet: false, ...redis.mode },+ storage: {+ ...SAVED_CONFIG.storage,+ type: 's3',+ s3Bucket: bucketFor('storage', savedHost('storage', storage)),+ s3Endpoint: savedHost('storage', storage),+ ...storage.mode,+ },},};const { container } = renderInfrastructure();@@ -1142,7 +1427,7 @@ COMBOS.forEach((_, i) => {assert.equal(toggleInput(container, label).checked, shownMode(combo), `${label} toggle`);assert.equal(hostPinNoteOf(container, label), combo.pin === 'none' ? null : hostKey, `${label} pin note`);const note =- !combo.mode.builtInSet || combo.mode.builtIn === combo.running+ !combo.mode.builtInSet || combo.mode.builtIn === containerRuns(combo)? null: combo.mode.builtIn? PENDING_BUILT_IN_NOTE@@ -1164,15 +1449,15 @@ COMBOS.forEach((_, i) => {[shownMode(database), shownMode(redis), shownMode(storage)],'the flags the save sends',);- // Only a database or storage whose shown mode differs from what runs starts empty after the restart.+ // Only a database or storage the next boot connects to somewhere else starts empty after the restart.assert.equal(within(dialog).queryByText(DB_SWITCH_WARNING, { exact: false }) !== null,- shownMode(database) !== database.running,+ nextHost('database', database) !== statusHost('database', database),'the database warning',);assert.equal(within(dialog).queryByText(STORAGE_WARNING, { exact: false }) !== null,- shownMode(storage) !== storage.running,+ nextHost('storage', storage) !== statusHost('storage', storage),'the storage warning',);});diff --git a/dashboard/src/pages/Infrastructure.tsx b/dashboard/src/pages/Infrastructure.tsxindex a52c9d291..3c62163d4 100644--- a/dashboard/src/pages/Infrastructure.tsx+++ b/dashboard/src/pages/Infrastructure.tsx@@ -65,32 +65,40 @@ export function Infrastructure() {const configSave = useConfigSave({buildPayload: configForm.buildSavePayload,onSaved: profiles => {- // Flag a backend switch vs what's actually running so the restart modal can warn about the- // empty-database / orphaned-media data move before it happens. A switch is: changing type;- // flipping built-in↔external (different physical backend); OR retargeting an external Postgres- // to a different host/port/database (also a different, empty DB). Host/port/db aren't all in- // /status, so compare the edited form against the saved config as the page loaded it. A key with- // nothing saved reads '', and runs on the same fallback the form was seeded with.+ // Flag a backend switch so the restart modal can warn about the empty-database / orphaned-media data+ // move before it happens. A switch is a next boot that connects somewhere else than the server does+ // now: another type, host, port or database name, or another S3 endpoint or bucket. The next boot+ // connects to a value the environment pins whatever the form says, and to the bundled container for+ // a built-in choice. Whether that container runs right now is no part of it: a stopped one is started+ // again on the same volume. /status reports the type, host, endpoint and bucket in use; the port and+ // the database name are not on it, so those compare with the saved config as the page loaded it. A+ // key with nothing saved reads '', and runs on the same fallback the form was seeded with. A new local+ // path is no switch.const loaded = loadedConfig.current;+ const pinned = (key: string) => (infraStatus?.envPinned?.includes(key) ? loaded : undefined);+ const db = configForm.dbConfig;+ const dbType = pinned('DATABASE_TYPE')?.database.type ?? db.type;+ const dbHost =+ (pinned('DATABASE_HOST')?.database.host ?? (db.builtIn ? 'postgres' : db.host.trim())) || 'localhost';const dbExternalRetarget =- configForm.dbConfig.type === 'postgres' &&- !configForm.dbConfig.builtIn &&+ !db.builtIn &&!!loaded &&- (configForm.dbConfig.host !== (loaded.database.host || infraStatus?.database.host || 'localhost') ||- configForm.dbConfig.port !== (loaded.database.port || '5432') ||- configForm.dbConfig.database !== (loaded.database.database || 'openwa'));+ (db.port !== (loaded.database.port || '5432') || db.database !== (loaded.database.database || 'openwa'));const dbSwitch =!!infraStatus &&- (configForm.dbConfig.type !== infraStatus.database.type ||- (configForm.dbConfig.type === 'postgres' && configForm.dbConfig.builtIn !== infraStatus.database.builtIn) ||- dbExternalRetarget);- // Scope: this warns on a backend-TYPE change (local↔s3) and a built-in↔external flip — the cases- // that point at a different store. It does NOT warn on same-backend repointing (e.g. a new S3- // bucket/endpoint or a new local path); region/endpoint aren't on /status to compare reliably.+ (dbType !== infraStatus.database.type ||+ (dbType === 'postgres' && (dbHost !== infraStatus.database.host || dbExternalRetarget)));+ const storage = configForm.storageConfig;+ const storageType = pinned('STORAGE_TYPE')?.storage.type ?? storage.type;+ const endpoint =+ pinned('S3_ENDPOINT')?.storage.s3Endpoint ?? (storage.builtIn ? 'http://minio:9000' : storage.s3Endpoint);+ const bucket = (storage.builtIn ? 'openwa' : storage.s3Bucket) || 'openwa';const storageSwitch =!!infraStatus &&- (configForm.storageConfig.type !== infraStatus.storage.type ||- (configForm.storageConfig.type === 's3' && configForm.storageConfig.builtIn !== infraStatus.storage.builtIn));+ (storageType !== infraStatus.storage.type ||+ (storageType === 's3' &&+ (endpoint !== (infraStatus.storage.endpoint ?? '') ||+ bucket !== (infraStatus.storage.bucket || 'openwa'))));// The built-in containers running now, so the restart stops each one the new config dropped. With no// status read there is nothing to go on, and nothing is stopped.const running = [diff --git a/dashboard/src/services/api.ts b/dashboard/src/services/api.tsindex b1b2fad2d..aa856069d 100644--- a/dashboard/src/services/api.ts+++ b/dashboard/src/services/api.ts@@ -630,7 +630,15 @@ export interface InfraStatus {enabled: boolean;webhooks: { pending: number; completed: number; failed: number };};- storage: { type: 'local' | 's3'; path?: string; bucket?: string; builtIn: boolean; s3Available?: boolean };+ storage: {+ type: 'local' | 's3';+ path?: string;+ bucket?: string;+ // S3 only, when an endpoint is set: the one the server dials, which a stopped bundled MinIO still names.+ endpoint?: string;+ builtIn: boolean;+ s3Available?: boolean;+ };engine: {type: string;headless: boolean;diff --git a/docs/06-api-specification.md b/docs/06-api-specification.mdindex f86c2e298..7a2682882 100644--- a/docs/06-api-specification.md+++ b/docs/06-api-specification.md@@ -5527,7 +5527,7 @@ Aggregate infrastructure status (database, Redis, queue, storage, engine).The `queue.webhooks` counters are live BullMQ job counts (`pending` = waiting + active + delayed; plus `completed`/`failed`), degrading to zeros when the queue is disabled or Redis is unreachable. `redis.connected` is a live probe. `database.host` is the configured `DATABASE_HOST` (default `localhost`) and is reported on SQLite too, so read `type`, not `host`, to tell the database apart.-`builtIn` (on `database`/`redis`/`storage`) reports whether OpenWA's own bundled container is actually running _and_ backing this service, detected live from the labelled container; when Docker is unreachable it falls back to the saved `*_BUILTIN` flag (one pinned by the environment first, else the one in `data/.env.generated`), and a host name alone counts for nothing there, since an external server may be called `postgres`. In S3 mode `storage` additionally carries `bucket` (when one is configured) and `s3Available` (re-probed, throttled, while false; once true it stays true until a restart, so a later outage does not clear it); in local mode neither key is present. `engine.webVersion`/`engine.webVersionSource` (`pinned` / `auto` / `native`) appear only on `whatsapp-web.js`; `webVersion` is `null` until the auto-resolve first succeeds. `engine.browserArgs` is the effective launch argument list: `PUPPETEER_ARGS` (or the four defaults shown) with `--lang=en-US` appended unless a `--lang` flag is already present.+`builtIn` (on `database`/`redis`/`storage`) reports whether OpenWA's own bundled container is actually running _and_ backing this service, detected live from the labelled container; when Docker is unreachable it falls back to the saved `*_BUILTIN` flag (one pinned by the environment first, else the one in `data/.env.generated`), and a host name alone counts for nothing there, since an external server may be called `postgres`. In S3 mode `storage` additionally carries `bucket` and `endpoint` (each when one is configured; a bundled MinIO that is stopped still reports `http://minio:9000` here, with `builtIn` false) and `s3Available` (re-probed, throttled, while false; once true it stays true until a restart, so a later outage does not clear it); in local mode neither key is present. `engine.webVersion`/`engine.webVersionSource` (`pinned` / `auto` / `native`) appear only on `whatsapp-web.js`; `webVersion` is `null` until the auto-resolve first succeeds. `engine.browserArgs` is the effective launch argument list: `PUPPETEER_ARGS` (or the four defaults shown) with `--lang=en-US` appended unless a `--lang` flag is already present.`envPinned` lists which of `DATABASE_TYPE`, `DATABASE_HOST`, `REDIS_ENABLED`, `REDIS_HOST`, `STORAGE_TYPE`, `S3_ENDPOINT`, `STORAGE_LOCAL_PATH`, `ENGINE_TYPE`, `PUPPETEER_HEADLESS`, `SESSION_DATA_PATH` and `PUPPETEER_ARGS` the host environment or the project `.env` sets. Those layers win over `data/.env.generated`, so a value saved for one of these keys through `PUT /api/infra/config` cannot take effect until that layer is changed. A pinned host also decides whether the bundled container backs its service, whatever `builtIn` is saved.diff --git a/openapi.json b/openapi.jsonindex f511c5992..20d67ecbc 100644--- a/openapi.json+++ b/openapi.json@@ -22001,6 +22001,11 @@"description": "Bucket name. Present only for `s3`.","example": "openwa-media"},+ "endpoint": {+ "type": "string",+ "description": "S3 endpoint the app is configured to reach. Present only for `s3` with an endpoint set; absent for the default AWS endpoint.",+ "example": "http://minio:9000"+ },"builtIn": {"type": "boolean","description": "Whether OpenWA's bundled MinIO container is backing this.",diff --git a/src/modules/infra/dto/infra-response.dto.ts b/src/modules/infra/dto/infra-response.dto.tsindex 3abbbed04..27ce98305 100644--- a/src/modules/infra/dto/infra-response.dto.ts+++ b/src/modules/infra/dto/infra-response.dto.ts@@ -82,6 +82,14 @@ export class InfraStorageStatusDto {@ApiPropertyOptional({ description: 'Bucket name. Present only for `s3`.', example: 'openwa-media' })bucket?: string;+ @ApiPropertyOptional({+ description:+ 'S3 endpoint the app is configured to reach. Present only for `s3` with an endpoint set; absent for the ' ++ 'default AWS endpoint.',+ example: 'http://minio:9000',+ })+ endpoint?: string;+@ApiProperty({ description: "Whether OpenWA's bundled MinIO container is backing this.", example: false })builtIn!: boolean;diff --git a/src/modules/infra/infra-status.controller.spec.ts b/src/modules/infra/infra-status.controller.spec.tsindex 5d6c7f127..4a092879e 100644--- a/src/modules/infra/infra-status.controller.spec.ts+++ b/src/modules/infra/infra-status.controller.spec.ts@@ -230,6 +230,20 @@ describe('InfraStatusController.getStatus storage (reads the real storage.localPconst status = await buildController({ 'storage.type': 'local' }).getStatus();expect(status.storage.bucket).toBeUndefined();});++ // The endpoint this process dials, which tells a bundled MinIO that is stopped apart from an external store.+ it('reports the endpoint in S3 mode, and only there', async () => {+ const endpoint = 'http://minio:9000';+ const s3 = await buildController({ 'storage.type': 's3', 'storage.s3.endpoint': endpoint }).getStatus();+ const local = await buildController({ 'storage.type': 'local', 'storage.s3.endpoint': endpoint }).getStatus();+ const aws = await buildController({ 'storage.type': 's3' }).getStatus();++ expect([s3.storage.endpoint, local.storage.endpoint, aws.storage.endpoint]).toEqual([+ endpoint,+ undefined,+ undefined,+ ]);+ });});// #1082: the Infrastructure page used to INFER an environment pin from "running != saved", which alsodiff --git a/src/modules/infra/infra-status.controller.ts b/src/modules/infra/infra-status.controller.tsindex 3e1521e84..89be9509b 100644--- a/src/modules/infra/infra-status.controller.ts+++ b/src/modules/infra/infra-status.controller.ts@@ -38,7 +38,14 @@ interface InfraStatus {enabled: boolean;webhooks: { pending: number; completed: number; failed: number };};- storage: { type: 'local' | 's3'; path?: string; bucket?: string; builtIn: boolean; s3Available?: boolean };+ storage: {+ type: 'local' | 's3';+ path?: string;+ bucket?: string;+ endpoint?: string;+ builtIn: boolean;+ s3Available?: boolean;+ };engine: {type: string;headless: boolean;@@ -233,6 +240,8 @@ export class InfraStatusController {type: storageType,path: storagePath,...(storageType === 's3' && storageBucket ? { bucket: storageBucket } : {}),+ // The endpoint this process dials: a bundled MinIO that is stopped still names it, an external store does not.+ ...(storageType === 's3' && s3Endpoint ? { endpoint: s3Endpoint } : {}),builtIn: storageBuiltIn,...(storageType === 's3' ? { s3Available } : {}),},