From 95012dc19b79bf1c8546e4b8208a17c9dea6ba49 Mon Sep 17 00:00:00 2001 From: Jason Rasmussen Date: Fri, 24 May 2024 16:44:50 -0400 Subject: [PATCH] fix: config error logging (#9738) --- server/src/cores/system-config.core.ts | 1 + server/src/services/system-config.service.spec.ts | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/server/src/cores/system-config.core.ts b/server/src/cores/system-config.core.ts index 97d5fd82c6..b03fe482c3 100644 --- a/server/src/cores/system-config.core.ts +++ b/server/src/cores/system-config.core.ts @@ -137,6 +137,7 @@ export class SystemConfigCore { return loadYaml(file.toString()) as unknown; } catch (error: Error | any) { this.logger.error(`Unable to load configuration file: ${filepath}`); + this.logger.error(error); throw error; } } diff --git a/server/src/services/system-config.service.spec.ts b/server/src/services/system-config.service.spec.ts index d549267925..878916b0d2 100644 --- a/server/src/services/system-config.service.spec.ts +++ b/server/src/services/system-config.service.spec.ts @@ -231,6 +231,21 @@ describe(SystemConfigService.name, () => { expect(systemMock.readFile).toHaveBeenCalledWith('immich-config.json'); }); + it('should log errors with the config file', async () => { + process.env.IMMICH_CONFIG_FILE = 'immich-config.json'; + + systemMock.readFile.mockResolvedValue(`{ "ffmpeg2": true, "ffmpeg2": true }`); + + await expect(sut.getConfig()).rejects.toBeInstanceOf(Error); + + expect(systemMock.readFile).toHaveBeenCalledWith('immich-config.json'); + expect(loggerMock.error).toHaveBeenCalledTimes(2); + expect(loggerMock.error.mock.calls[0][0]).toEqual('Unable to load configuration file: immich-config.json'); + expect(loggerMock.error.mock.calls[1][0].toString()).toEqual( + expect.stringContaining('YAMLException: duplicated mapping key (1:20)'), + ); + }); + it('should load the config from a yaml file', async () => { process.env.IMMICH_CONFIG_FILE = 'immich-config.yaml'; const partialConfig = `