Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(config): reject a typo in the media-conversion/archive enable flags at boot
Yudhi Armyndharis9882945c87c8
diff --git a/src/config/env.validation.spec.ts b/src/config/env.validation.spec.tsindex 44853c338..997b8e98e 100644--- a/src/config/env.validation.spec.ts+++ b/src/config/env.validation.spec.ts@@ -158,6 +158,19 @@ describe('validateEnv', () => {expect(() => validateEnv({})).not.toThrow();});+ it.each(['MEDIA_CONVERSION_ENABLED', 'CHAT_MEDIA_ARCHIVE_ENABLED'])(+ 'rejects a %s typo instead of silently leaving the feature off',+ key => {+ // Both are read at boot with `=== 'true'`, so a typo silently disables the feature and the+ // endpoints answer as if it was never configured — the same silent-off class as SEND_PACING.+ expect(() => validateEnv({ [key]: 'ture' })).toThrow(new RegExp(key));+ expect(() => validateEnv({ [key]: 'True' })).toThrow(new RegExp(key));+ expect(() => validateEnv({ [key]: 'true' })).not.toThrow();+ expect(() => validateEnv({ [key]: 'false' })).not.toThrow();+ expect(() => validateEnv({ [key]: '' })).not.toThrow();+ },+ );+it('rejects a SEARCH_PROVIDER typo instead of silently falling back to auto', () => {// A bogus / typo value must fail fast at boot rather than silently selecting the default provider.expect(() => validateEnv({ SEARCH_PROVIDER: 'bogus' })).toThrow(/SEARCH_PROVIDER/);diff --git a/src/config/env.validation.ts b/src/config/env.validation.tsindex 5f2e45712..74655b861 100644--- a/src/config/env.validation.ts+++ b/src/config/env.validation.ts@@ -246,6 +246,10 @@ export function validateEnv(config: EnvConfig): EnvConfig {// Read with `=== 'true'`, so a typo leaves sends unpaced — the silent failure this whole// feature exists to avoid, and invisible without this check.'SEND_PACING_ENABLED',+ // Opt-in feature flags read with `=== 'true'`: a typo silently leaves the feature OFF, so the+ // conversion/archive endpoints answer as if nothing was configured. Same class as the above.+ 'MEDIA_CONVERSION_ENABLED',+ 'CHAT_MEDIA_ARCHIVE_ENABLED',]) {checkBool(key);}