Merge pull request #5103 from shuv-o/fix/project-permission-column-limit

fix: prevent Postgres 100-arg limit crash and restore data parity for restricted-member project access
(cherry picked from commit 6d8aa9d8da)

[skip ci]
This commit is contained in:
Mauricio Siu
2026-08-17 01:42:50 -06:00
committed by Dokploy Bot
parent e541308a4f
commit a691b469a1
2 changed files with 34 additions and 9 deletions
@@ -38,6 +38,7 @@ import {
checkProjectAccess,
findMemberByUserId,
} from "@dokploy/server/services/permission";
import { serviceColumns } from "@dokploy/server/services/project";
import { TRPCError } from "@trpc/server";
import { and, desc, eq, ilike, or, sql } from "drizzle-orm";
import type { AnyPgColumn } from "drizzle-orm/pg-core";
@@ -130,39 +131,63 @@ export const projectRouter = createTRPCRouter({
environments: {
with: {
applications: {
columns: {
...serviceColumns,
applicationId: true,
icon: true,
},
with: { server: { columns: { name: true } } },
where: buildServiceFilter(
applications.applicationId,
accessedServices,
),
},
compose: {
columns: {
...serviceColumns,
composeId: true,
composeStatus: true,
},
with: { server: { columns: { name: true } } },
where: buildServiceFilter(
compose.composeId,
accessedServices,
),
},
libsql: {
columns: { ...serviceColumns, libsqlId: true },
with: { server: { columns: { name: true } } },
where: buildServiceFilter(libsql.libsqlId, accessedServices),
},
mariadb: {
columns: { ...serviceColumns, mariadbId: true },
with: { server: { columns: { name: true } } },
where: buildServiceFilter(
mariadb.mariadbId,
accessedServices,
),
},
mongo: {
columns: { ...serviceColumns, mongoId: true },
with: { server: { columns: { name: true } } },
where: buildServiceFilter(mongo.mongoId, accessedServices),
},
mysql: {
columns: { ...serviceColumns, mysqlId: true },
with: { server: { columns: { name: true } } },
where: buildServiceFilter(mysql.mysqlId, accessedServices),
},
postgres: {
columns: { ...serviceColumns, postgresId: true },
with: { server: { columns: { name: true } } },
where: buildServiceFilter(
postgres.postgresId,
accessedServices,
),
},
redis: {
columns: { ...serviceColumns, redisId: true },
with: { server: { columns: { name: true } } },
where: buildServiceFilter(redis.redisId, accessedServices),
},
},
+9 -9
View File
@@ -47,16 +47,16 @@ export const createProject = async (
};
};
export const findProjectById = async (projectId: string) => {
const serviceColumns = {
name: true,
description: true,
appName: true,
createdAt: true,
serverId: true,
applicationStatus: true,
} as const;
export const serviceColumns = {
name: true,
description: true,
appName: true,
createdAt: true,
serverId: true,
applicationStatus: true,
} as const;
export const findProjectById = async (projectId: string) => {
const project = await db.query.projects.findFirst({
where: eq(projects.projectId, projectId),
with: {