Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Fix error schema validation issue

Fang-Pen Lin4d9b74c85bf0
diff --git a/backend/src/server/plugins/add-errors-to-response-schemas.ts b/backend/src/server/plugins/add-errors-to-response-schemas.ts
index 8eb358a1b4..6337bae0f4 100644
--- a/backend/src/server/plugins/add-errors-to-response-schemas.ts
+++ b/backend/src/server/plugins/add-errors-to-response-schemas.ts
@@ -6,9 +6,16 @@ import { DefaultResponseErrorsSchema } from "../routes/sanitizedSchemas";
const isScimRoutes = (pathname: string) =>
pathname.startsWith("/api/v1/scim/Users") || pathname.startsWith("/api/v1/scim/Groups");
+const isAcmeRoutes = (pathname: string) => pathname.startsWith("/api/v1/pki/acme/");
+
export const addErrorsToResponseSchemas = fp(async (server) => {
server.addHook("onRoute", (routeOptions) => {
- if (routeOptions.schema && routeOptions.schema.response && !isScimRoutes(routeOptions.path)) {
+ if (
+ routeOptions.schema &&
+ routeOptions.schema.response &&
+ !isScimRoutes(routeOptions.path) &&
+ !isAcmeRoutes(routeOptions.path)
+ ) {
routeOptions.schema.response = {
...DefaultResponseErrorsSchema,
...routeOptions.schema.response
diff --git a/backend/src/server/plugins/error-handler.ts b/backend/src/server/plugins/error-handler.ts
index ecaa60c998..4b29f69305 100644
--- a/backend/src/server/plugins/error-handler.ts
+++ b/backend/src/server/plugins/error-handler.ts
@@ -250,7 +250,7 @@ export const fastifyErrHandler = fastifyPlugin(async (server: FastifyZodProvider
.send({
reqId: req.id,
error: error.name,
- statusCode: error.status,
+ status: error.status,
type: `urn:ietf:params:acme:error:${error.type}`,
detail: error.detail,
message: error.message