Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

🛠️ fix: Ensure `imageOutputType` is Always Defined (#2438)

Danny Avila3c184e94109e
diff --git a/api/server/services/AppService.js b/api/server/services/AppService.js
index 59d1163d79..e444594b4a 100644
--- a/api/server/services/AppService.js
+++ b/api/server/services/AppService.js
@@ -36,6 +36,7 @@ const AppService = async (app) => {
const config = (await loadCustomConfig()) ?? {};
const fileStrategy = config.fileStrategy ?? FileSources.local;
+ const imageOutputType = config?.imageOutputType ?? EImageOutputType.PNG;
process.env.CDN_PROVIDER = fileStrategy;
if (fileStrategy === FileSources.firebase) {
@@ -58,9 +59,10 @@ const AppService = async (app) => {
if (!Object.keys(config).length) {
app.locals = {
- availableTools,
fileStrategy,
socialLogins,
+ availableTools,
+ imageOutputType,
paths,
};
@@ -177,12 +179,12 @@ const AppService = async (app) => {
app.locals = {
socialLogins,
- availableTools,
fileStrategy,
+ availableTools,
+ imageOutputType,
fileConfig: config?.fileConfig,
interface: config?.interface,
secureImageLinks: config?.secureImageLinks,
- imageOutputType: config?.imageOutputType?.toLowerCase() ?? EImageOutputType.PNG,
paths,
...endpointLocals,
};
diff --git a/api/server/services/AppService.spec.js b/api/server/services/AppService.spec.js
index 572871e100..dd8e0c0068 100644
--- a/api/server/services/AppService.spec.js
+++ b/api/server/services/AppService.spec.js
@@ -139,7 +139,6 @@ describe('AppService', () => {
);
await AppService(app);
-
expect(app.locals.imageOutputType).toEqual(EImageOutputType.WEBP);
});
@@ -151,7 +150,15 @@ describe('AppService', () => {
);
await AppService(app);
+ expect(app.locals.imageOutputType).toEqual(EImageOutputType.PNG);
+ });
+ it('should default to `PNG` `imageOutputType` with no provided config', async () => {
+ require('./Config/loadCustomConfig').mockImplementationOnce(() =>
+ Promise.resolve(undefined),
+ );
+
+ await AppService(app);
expect(app.locals.imageOutputType).toEqual(EImageOutputType.PNG);
});
diff --git a/api/server/services/Files/images/avatar.js b/api/server/services/Files/images/avatar.js
index 1041e91b07..3c1068a453 100644
--- a/api/server/services/Files/images/avatar.js
+++ b/api/server/services/Files/images/avatar.js
@@ -1,6 +1,7 @@
const sharp = require('sharp');
const fs = require('fs').promises;
const fetch = require('node-fetch');
+const { EImageOutputType } = require('librechat-data-provider');
const { resizeAndConvert } = require('./resize');
const { logger } = require('~/config');
@@ -20,7 +21,7 @@ const { logger } = require('~/config');
* @throws {Error} Throws an error if the user ID is undefined, the input type is invalid, the image fetching fails,
* or any other error occurs during the processing.
*/
-async function resizeAvatar({ userId, input, desiredFormat }) {
+async function resizeAvatar({ userId, input, desiredFormat = EImageOutputType.PNG }) {
try {
if (userId === undefined) {
throw new Error('User ID is undefined');