Dokploy/dokploy · error · TRPCError
BAD_REQUEST
BAD_REQUEST
Error message
Error input: Inserting redis database
What it means
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.
Source
Thrown at packages/server/src/services/redis.ts:44
code: "CONFLICT",
message: "Service with this 'AppName' already exists",
});
}
const newRedis = await db
.insert(redis)
.values({
...input,
databasePassword: input.databasePassword
? input.databasePassword
: generatePassword(),
appName,
})
.returning()
.then((value) => value[0]);
if (!newRedis) {
throw new TRPCError({
code: "BAD_REQUEST",
message: "Error input: Inserting redis database",
});
}
return newRedis;
};
export const findRedisById = async (redisId: string) => {
const result = await db.query.redis.findFirst({
where: eq(redis.redisId, redisId),
with: {
environment: {
with: {
project: true,
},
},
mounts: true,View on GitHub (pinned to 546686ea35)
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
Example fix
// before
const newRedis = await db.insert(redis).values({ ...input, appName }).returning().then(v => v[0]);
if (!newRedis) { throw new TRPCError({ code: "BAD_REQUEST", message: "Error input: Inserting redis database" }); }
// after (surface the real DB error)
const newRedis = await db.insert(redis).values({ ...input, appName }).returning().catch((e) => {
throw new TRPCError({ code: "BAD_REQUEST", message: "Error input: Inserting redis database", cause: e });
}).then(v => v[0]);
if (!newRedis) { throw new TRPCError({ code: "BAD_REQUEST", message: "Error input: Inserting redis database" }); } Defensive patterns
Strategy: validation
Validate before calling
// Validate required fields and uniqueness before calling
import { apiCreateRedis } from "@dokploy/server/db/schema";
const parsed = apiCreateRedis.safeParse(input);
if (!parsed.success) throw new Error(parsed.error.message); Type guard
const isRedisRow = (v: unknown): v is { redisId: string; appName: string } =>
typeof v === "object" && v !== null && "redisId" in v && "appName" in v; Try / catch
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; } Prevention
- Keep drizzle migrations in sync with the schema before deploying
- Zod-validate the create payload client-side before hitting the API
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: BAD_REQUEST error code: request rejected as invalid (HTTP 400) - causes and fixes across libraries — this error's family across 8 libraries.
Related errors
AI-assisted analysis of Dokploy/dokploy@546686ea35 (2026-08-27).
Data as JSON: /api/errors/85f539b590e52575.
Report an issue: GitHub.