fix: mcp not response output (#5388)

This commit is contained in:
Archer
2025-08-05 10:51:42 +08:00
committed by GitHub
parent f870a2de52
commit 37648d5c71
4 changed files with 13 additions and 5 deletions

View File

@@ -7,6 +7,7 @@ import { readFromSecondary } from '../../mongo/utils';
import { addHours } from 'date-fns';
import { imageFileType } from '@fastgpt/global/common/file/constants';
import { retryFn } from '@fastgpt/global/common/system/utils';
import { UserError } from '@fastgpt/global/common/error/utils';
export const maxImgSize = 1024 * 1024 * 12;
const base64MimeRegex = /data:image\/([^\)]+);base64/;
@@ -105,7 +106,7 @@ export async function readMongoImg({ id }: { id: string }) {
...readFromSecondary
});
if (!data) {
return Promise.reject('Image not found');
return Promise.reject(new UserError('Image not found'));
}
return {

View File

@@ -4,6 +4,7 @@ import { proxyError, ERROR_RESPONSE, ERROR_ENUM } from '@fastgpt/global/common/e
import { addLog } from '../system/log';
import { clearCookie } from '../../support/permission/controller';
import { replaceSensitiveText } from '@fastgpt/global/common/string/tools';
import { UserError } from '@fastgpt/global/common/error/utils';
export interface ResponseType<T = any> {
code: number;
@@ -59,7 +60,11 @@ export const jsonRes = <T = any>(
msg = error?.error?.message;
}
addLog.error(`Api response error: ${url}, ${msg}`, error);
if (error instanceof UserError) {
addLog.info(`Request error: ${url}, ${msg}`);
} else {
addLog.error(`System unexpected error: ${url}, ${msg}`, error);
}
}
res.status(code).json({