Skip to content

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

Add error handling

Fang-Pen Linc6981671af6d
diff --git a/backend/src/ee/services/pki-acme/pki-acme-service.ts b/backend/src/ee/services/pki-acme/pki-acme-service.ts
index 098046ffc1..bcb3f07c7b 100644
--- a/backend/src/ee/services/pki-acme/pki-acme-service.ts
+++ b/backend/src/ee/services/pki-acme/pki-acme-service.ts
@@ -288,7 +288,7 @@ export const pkiAcmeServiceFactory = ({
await acmeOrderAuthDAL.insertMany(
authorizations.map((auth) => ({
- orderId: order.id,
+ orderId: createdOrder.id,
authId: auth.id
}))
);
diff --git a/backend/src/server/plugins/error-handler.ts b/backend/src/server/plugins/error-handler.ts
index 8d10a86306..50251377d3 100644
--- a/backend/src/server/plugins/error-handler.ts
+++ b/backend/src/server/plugins/error-handler.ts
@@ -5,6 +5,7 @@ import fastifyPlugin from "fastify-plugin";
import jwt from "jsonwebtoken";
import { ZodError } from "zod";
+import { AcmeError } from "@app/ee/services/pki-acme/pki-acme-errors";
import { getConfig } from "@app/lib/config/env";
import {
BadRequestError,
@@ -242,6 +243,16 @@ export const fastifyErrHandler = fastifyPlugin(async (server: FastifyZodProvider
error: "TokenError",
message: errorMessage
});
+ } else if (error instanceof AcmeError) {
+ void res
+ .type("application/problem+json")
+ .status(error.status)
+ .send({
+ status: error.status,
+ type: `urn:ietf:params:acme:error:${error.type}`,
+ detail: error.detail
+ // TODO: add subproblems if they exist
+ });
} else {
void res.status(HttpStatusCodes.InternalServerError).send({
reqId: req.id,