revert: go back to a literal 25mb body limit for deploy webhooks

This commit is contained in:
Souvik Kumar
2026-09-29 20:00:05 +05:30
parent 1c6d333739
commit 82545bf500
5 changed files with 11 additions and 39 deletions
@@ -62,12 +62,7 @@ vi.mock("@dokploy/server/db", () => ({
},
}));
vi.mock("next/dist/server/api-utils/node/parse-body", () => ({
parseBody: async (req: { body: unknown }) => req.body,
}));
vi.mock("@dokploy/server", () => ({
DEPLOY_WEBHOOK_MAX_BODY_SIZE: 25 * 1024 * 1024,
IS_CLOUD: false,
shouldDeploy: mocks.shouldDeploy,
checkUserRepositoryPermissions: vi.fn(),
@@ -1,6 +1,5 @@
import {
type Bitbucket,
DEPLOY_WEBHOOK_MAX_BODY_SIZE,
getBitbucketHeaders,
IS_CLOUD,
shouldDeploy,
@@ -8,7 +7,6 @@ import {
import { db } from "@dokploy/server/db";
import { eq } from "drizzle-orm";
import type { NextApiRequest, NextApiResponse } from "next";
import { parseBody } from "next/dist/server/api-utils/node/parse-body";
import { applications } from "@/server/db/schema";
import type { DeploymentJob } from "@/server/queues/queue-types";
import { myQueue } from "@/server/queues/queueSetup";
@@ -36,7 +34,9 @@ const getPackageVersion = (headers: any, body: any) => {
export const config = {
api: {
bodyParser: false,
bodyParser: {
sizeLimit: "25mb",
},
},
};
@@ -44,11 +44,6 @@ export default async function handler(
req: NextApiRequest,
res: NextApiResponse,
) {
if (Number(req.headers["content-length"]) > DEPLOY_WEBHOOK_MAX_BODY_SIZE) {
res.status(413).json({ message: "Payload too large" });
return;
}
req.body = await parseBody(req, DEPLOY_WEBHOOK_MAX_BODY_SIZE);
const { refreshToken } = req.query;
try {
if (req.headers["x-github-event"] === "ping") {
@@ -1,12 +1,7 @@
import {
DEPLOY_WEBHOOK_MAX_BODY_SIZE,
IS_CLOUD,
shouldDeploy,
} from "@dokploy/server";
import { IS_CLOUD, shouldDeploy } from "@dokploy/server";
import { db } from "@dokploy/server/db";
import { eq } from "drizzle-orm";
import type { NextApiRequest, NextApiResponse } from "next";
import { parseBody } from "next/dist/server/api-utils/node/parse-body";
import { compose } from "@/server/db/schema";
import type { DeploymentJob } from "@/server/queues/queue-types";
import { myQueue } from "@/server/queues/queueSetup";
@@ -22,7 +17,9 @@ import {
export const config = {
api: {
bodyParser: false,
bodyParser: {
sizeLimit: "25mb",
},
},
};
@@ -30,11 +27,6 @@ export default async function handler(
req: NextApiRequest,
res: NextApiResponse,
) {
if (Number(req.headers["content-length"]) > DEPLOY_WEBHOOK_MAX_BODY_SIZE) {
res.status(413).json({ message: "Payload too large" });
return;
}
req.body = await parseBody(req, DEPLOY_WEBHOOK_MAX_BODY_SIZE);
const { refreshToken } = req.query;
try {
if (req.headers["x-github-event"] === "ping") {
+3 -8
View File
@@ -2,7 +2,6 @@ import {
checkUserRepositoryPermissions,
createPreviewDeployment,
createSecurityBlockedComment,
DEPLOY_WEBHOOK_MAX_BODY_SIZE,
findGithubById,
findPreviewDeploymentByApplicationId,
findPreviewDeploymentsByPullRequestId,
@@ -14,7 +13,6 @@ import { db } from "@dokploy/server/db";
import { Webhooks } from "@octokit/webhooks";
import { and, eq } from "drizzle-orm";
import type { NextApiRequest, NextApiResponse } from "next";
import { parseBody } from "next/dist/server/api-utils/node/parse-body";
import { applications, compose, github } from "@/server/db/schema";
import type { DeploymentJob } from "@/server/queues/queue-types";
import { myQueue } from "@/server/queues/queueSetup";
@@ -30,7 +28,9 @@ const getGithubRepositoryOwner = (githubBody: any) =>
export const config = {
api: {
bodyParser: false,
bodyParser: {
sizeLimit: "25mb",
},
},
};
@@ -38,11 +38,6 @@ export default async function handler(
req: NextApiRequest,
res: NextApiResponse,
) {
if (Number(req.headers["content-length"]) > DEPLOY_WEBHOOK_MAX_BODY_SIZE) {
res.status(413).json({ message: "Payload too large" });
return;
}
req.body = await parseBody(req, DEPLOY_WEBHOOK_MAX_BODY_SIZE);
const signature = req.headers["x-hub-signature-256"];
if (!signature) {
res.status(401).json({ message: "Missing signature header" });
+1 -6
View File
@@ -13,7 +13,7 @@ export const DOKPLOY_DOCKER_PORT = process.env.DOKPLOY_DOCKER_PORT
export const CLEANUP_CRON_JOB = "50 23 * * *";
// Body size limits for the OpenAPI catch-all route (pages/api/[...trpc].ts) and the deploy webhooks (pages/api/deploy/*).
// Body size limits for the OpenAPI catch-all route (pages/api/[...trpc].ts).
const parseByteSize = (envVar: string, fallback: number): number => {
const raw = process.env[envVar];
if (!raw) return fallback;
@@ -35,11 +35,6 @@ export const OPENAPI_MAX_UPLOAD_SIZE = parseByteSize(
1024 * 1024 * 1024, // 1gb
);
export const DEPLOY_WEBHOOK_MAX_BODY_SIZE = parseByteSize(
"DEPLOY_WEBHOOK_MAX_BODY_SIZE",
25 * 1024 * 1024, // 25mb, GitHub's max webhook payload
);
type DockerSocketCandidate = {
label: string;
path: string;