{"record":{"id":"85f539b590e52575","repo":"Dokploy/dokploy","slug":"bad-request-85f539","errorCode":"BAD_REQUEST","errorMessage":"Error input: Inserting redis database","messagePattern":"Error input: Inserting redis database","errorType":"exception","errorClass":"TRPCError","httpStatus":400,"severity":"error","filePath":"packages/server/src/services/redis.ts","lineNumber":44,"sourceCode":"\t\t\tcode: \"CONFLICT\",\n\t\t\tmessage: \"Service with this 'AppName' already exists\",\n\t\t});\n\t}\n\n\tconst newRedis = await db\n\t\t.insert(redis)\n\t\t.values({\n\t\t\t...input,\n\t\t\tdatabasePassword: input.databasePassword\n\t\t\t\t? input.databasePassword\n\t\t\t\t: generatePassword(),\n\t\t\tappName,\n\t\t})\n\t\t.returning()\n\t\t.then((value) => value[0]);\n\n\tif (!newRedis) {\n\t\tthrow new TRPCError({\n\t\t\tcode: \"BAD_REQUEST\",\n\t\t\tmessage: \"Error input: Inserting redis database\",\n\t\t});\n\t}\n\n\treturn newRedis;\n};\n\nexport const findRedisById = async (redisId: string) => {\n\tconst result = await db.query.redis.findFirst({\n\t\twhere: eq(redis.redisId, redisId),\n\t\twith: {\n\t\t\tenvironment: {\n\t\t\t\twith: {\n\t\t\t\t\tproject: true,\n\t\t\t\t},\n\t\t\t},\n\t\t\tmounts: true,","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/packages/server/src/services/redis.ts#L26-L62","documentation":"Thrown by createRedis in Dokploy's server service when the drizzle ORM insert into the `redis` table with .returning() yields no first row. In practice the row is almost always inserted; this error surfaces when the insert silently returns zero rows (e.g. empty values object, failed default generation, or a DB-level constraint/trigger swallowing the insert inside a wrapper). It is a BAD_REQUEST TRPCError, so it propagates to the tRPC client as a 400.","triggerScenarios":"Calling the redis.create tRPC mutation (createRedis service) where the composed values object is empty/invalid, generatePassword() fails, or the postgres INSERT ... RETURNING returns no row (malformed input after zod parsing, schema drift between the drizzle schema and the actual database table).","commonSituations":"Running migrations out of sync with the drizzle schema, passing a partial input that zod coerces to empty defaults, or a database that rejects the row (NOT NULL without default on a column the code does not set) in an environment where the error is masked into the !newRedis branch.","solutions":["Check the server logs for the underlying drizzle/postgres error emitted just before this TRPCError is thrown","Run database migrations (drizzle-kit push/migrate) so the `redis` table matches packages/server db schema","Verify the apiCreateRedis zod input being sent contains all required fields (dockerImage, appName, environmentId, etc.)","Inspect the composed insert values by logging them before db.insert(redis) to spot empty/undefined required columns"],"exampleFix":"// before\nconst newRedis = await db.insert(redis).values({ ...input, appName }).returning().then(v => v[0]);\nif (!newRedis) { throw new TRPCError({ code: \"BAD_REQUEST\", message: \"Error input: Inserting redis database\" }); }\n\n// after (surface the real DB error)\nconst newRedis = await db.insert(redis).values({ ...input, appName }).returning().catch((e) => {\n  throw new TRPCError({ code: \"BAD_REQUEST\", message: \"Error input: Inserting redis database\", cause: e });\n}).then(v => v[0]);\nif (!newRedis) { throw new TRPCError({ code: \"BAD_REQUEST\", message: \"Error input: Inserting redis database\" }); }","handlingStrategy":"validation","validationCode":"// Validate required fields and uniqueness before calling\nimport { apiCreateRedis } from \"@dokploy/server/db/schema\";\nconst parsed = apiCreateRedis.safeParse(input);\nif (!parsed.success) throw new Error(parsed.error.message);","typeGuard":"const isRedisRow = (v: unknown): v is { redisId: string; appName: string } =>\n  typeof v === \"object\" && v !== null && \"redisId\" in v && \"appName\" in v;","tryCatchPattern":"try { await createRedis(input); } catch (e) { if (e instanceof TRPCError && e.code === \"BAD_REQUEST\" && /Inserting redis/.test(e.message)) { /* inspect DB logs/migrations */ } throw e; }","preventionTips":["Keep drizzle migrations in sync with the schema before deploying","Zod-validate the create payload client-side before hitting the API"],"tags":["dokploy","redis","drizzle","database-insert","trpc"],"backgroundTag":"database-insert-failed","analyzedSha":"546686ea3587f12ec5652217dedd9f7960fb6d15","analyzedAt":"2026-08-27T05:18:58.095Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}