Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(infra): accept the legacy S3 key names on config save and read
Yudhi Armyndharis77389ffd3b85
diff --git a/src/modules/infra/infra-config.controller.spec.ts b/src/modules/infra/infra-config.controller.spec.tsindex 7d421a4c3..31754bc9f 100644--- a/src/modules/infra/infra-config.controller.spec.ts+++ b/src/modules/infra/infra-config.controller.spec.ts@@ -941,6 +941,8 @@ describe('InfraConfigController.saveConfig built-in/external mode flips and the'STORAGE_TYPE','S3_ACCESS_KEY_ID','S3_SECRET_ACCESS_KEY',+ 'S3_ACCESS_KEY',+ 'S3_SECRET_KEY','S3_ENDPOINT','MINIO_BUILTIN','REDIS_PASSWORD',@@ -998,6 +1000,17 @@ describe('InfraConfigController.saveConfig built-in/external mode flips and the);});+ it('accepts external S3 credentials supplied under the legacy names boot still reads', () => {+ // main.ts and storage.service fall back to S3_ACCESS_KEY / S3_SECRET_KEY when the canonical+ // names are unset, so a deployment configured that way boots and must be able to save.+ process.env.STORAGE_TYPE = 's3';+ process.env.S3_ENDPOINT = 'https://s3.example.com';+ process.env.S3_ACCESS_KEY = 'AKIAEXAMPLESTRONG1';+ process.env.S3_SECRET_KEY = 'Sup3rSecretS3Key!';+ const env = written({ queue: { enabled: false } });+ expect(env).toContain('QUEUE_ENABLED=false');+ });+// The cases above delete every guard key from process.env, which cannot happen in production:// load-env merges data/.env.generated INTO process.env at boot, so the file's own values are// sitting there while this save runs. Reading them back as if they were an orchestrator@@ -1104,6 +1117,21 @@ describe('InfraConfigController.getConfig (#226)', () => {expect(JSON.stringify(cfg)).not.toContain('secret');expect(JSON.stringify(cfg)).not.toContain('"ak"');});++ it('reports S3 credentials set under the legacy names the runtime still reads', () => {+ recordPinnedEnvKeys({ S3_ACCESS_KEY: 'ak', S3_SECRET_KEY: 'sk' });+ process.env.S3_ACCESS_KEY = 'ak';+ process.env.S3_SECRET_KEY = 'sk';+ try {+ expect(+ new InfraConfigController({} as never, {} as never, {} as never).getConfig().storage.s3CredentialsSet,+ ).toBe(true);+ } finally {+ delete process.env.S3_ACCESS_KEY;+ delete process.env.S3_SECRET_KEY;+ recordPinnedEnvKeys({});+ }+ });});describe('InfraConfigController.getConfig reflects environment-pinned values (#1313)', () => {diff --git a/src/modules/infra/infra-config.controller.ts b/src/modules/infra/infra-config.controller.tsindex 9f4f3be64..513364bee 100644--- a/src/modules/infra/infra-config.controller.ts+++ b/src/modules/infra/infra-config.controller.ts@@ -172,7 +172,10 @@ export class InfraConfigController {s3Bucket: effective('S3_BUCKET') || '',s3Region: effective('S3_REGION') || '',s3Endpoint: effective('S3_ENDPOINT') || '',- s3CredentialsSet: Boolean(effective('S3_ACCESS_KEY_ID') && effective('S3_SECRET_ACCESS_KEY')),+ s3CredentialsSet: Boolean(+ (effective('S3_ACCESS_KEY_ID') || effective('S3_ACCESS_KEY')) &&+ (effective('S3_SECRET_ACCESS_KEY') || effective('S3_SECRET_KEY')),+ ),},engine: {type: effective('ENGINE_TYPE') || 'whatsapp-web.js',@@ -324,8 +327,9 @@ export class InfraConfigController {postgresBuiltIn: bootValue('POSTGRES_BUILTIN'),databaseHost: bootValue('DATABASE_HOST'),storageType: bootValue('STORAGE_TYPE'),- s3AccessKey: bootValue('S3_ACCESS_KEY_ID'),- s3SecretKey: bootValue('S3_SECRET_ACCESS_KEY'),+ // The same canonical-with-legacy fallback main.ts and storage.service apply.+ s3AccessKey: bootValue('S3_ACCESS_KEY_ID') || bootValue('S3_ACCESS_KEY'),+ s3SecretKey: bootValue('S3_SECRET_ACCESS_KEY') || bootValue('S3_SECRET_KEY'),s3Endpoint: bootValue('S3_ENDPOINT'),minioBuiltIn: bootValue('MINIO_BUILTIN'),redisPassword: bootValue('REDIS_PASSWORD'),