From 335216f6ddc7f4881c3e114b9ebf0115ba0b5d82 Mon Sep 17 00:00:00 2001 From: Jason Rasmussen Date: Tue, 17 Oct 2023 17:34:16 -0400 Subject: [PATCH] feat(server): allow underscores in ML url (#4517) --- .../dto/system-config-machine-learning.dto.ts | 2 +- .../domain/system-config/system-config.service.spec.ts | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/server/src/domain/system-config/dto/system-config-machine-learning.dto.ts b/server/src/domain/system-config/dto/system-config-machine-learning.dto.ts index 330560ea87..38d977f886 100644 --- a/server/src/domain/system-config/dto/system-config-machine-learning.dto.ts +++ b/server/src/domain/system-config/dto/system-config-machine-learning.dto.ts @@ -6,7 +6,7 @@ export class SystemConfigMachineLearningDto { @IsBoolean() enabled!: boolean; - @IsUrl({ require_tld: false }) + @IsUrl({ require_tld: false, allow_underscores: true }) @ValidateIf((dto) => dto.enabled) url!: string; diff --git a/server/src/domain/system-config/system-config.service.spec.ts b/server/src/domain/system-config/system-config.service.spec.ts index ecdec41fd0..d47b0ea7cc 100644 --- a/server/src/domain/system-config/system-config.service.spec.ts +++ b/server/src/domain/system-config/system-config.service.spec.ts @@ -189,6 +189,15 @@ describe(SystemConfigService.name, () => { expect(configMock.readFile).toHaveBeenCalledWith('immich-config.json'); }); + it('should allow underscores in the machine learning url', async () => { + process.env.IMMICH_CONFIG_FILE = 'immich-config.json'; + const partialConfig = { machineLearning: { url: 'immich_machine_learning' } }; + configMock.readFile.mockResolvedValue(Buffer.from(JSON.stringify(partialConfig))); + + const config = await sut.getConfig(); + expect(config.machineLearning.url).toEqual('immich_machine_learning'); + }); + const tests = [ { should: 'validate numbers', config: { ffmpeg: { crf: 'not-a-number' } } }, { should: 'validate booleans', config: { oauth: { enabled: 'invalid' } } },