Open FelixMalfait opened 1 month ago
To resolve the issue of returning a 400 status code instead of a 500 for query read timeouts, follow these steps:
Update RestApiException
:
/packages/twenty-server/src/engine/api/rest/errors/RestApiException.ts
import { InternalServerErrorException } from '@nestjs/common';
export class RestApiException extends InternalServerErrorException { constructor(errors: BaseGraphQLError[]) { super({ statusCode: 500, message: errors.length === 1 ? formatMessage(errors[0]) : JSON.stringify(errors.map((error) => formatMessage(error))), error: 'Internal Server Error', }); } }
Update OpenAPI Utils:
/packages/twenty-server/src/engine/core-modules/open-api/utils/get-error-responses.utils.ts
export const get500ErrorResponses = (): OpenAPIV3_1.ResponseObject => {
return {
description: 'Internal Server Error',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
statusCode: { type: 'number' },
message: { type: 'string' },
error: { type: 'string' },
},
example: {
statusCode: 500,
message: 'Query read timeout',
error: 'Internal Server Error',
},
},
},
},
};
};
/packages/twenty-server/src/engine/core-modules/open-api/utils/get-error-responses.utils.ts /packages/twenty-server/src/engine/api/rest/errors/RestApiException.ts /packages/twenty-server/src/core/api-rest/api-rest.controller.utils.ts /packages/twenty-server/src/core/api-rest/api-rest.controller.utils.spec.ts
idk but is there any user rate limit on the server side? although i have seen rate limit on the application level for some end points
There is one but it's quite high right now. We will lower it as user will start spamming the platform :p
A client reported that they ran the following request:
And got the following error:
This didn't appear in Sentry. This should have been a 500 not a 400 as the request is correct. Where could this come from @charlesBochet?