{"record":{"id":"664e32127afb8ba7","repo":"Dokploy/dokploy","slug":"bad-request-664e32","errorCode":"BAD_REQUEST","errorMessage":"Error input: Inserting libsql database","messagePattern":"Error input: Inserting libsql database","errorType":"exception","errorClass":"TRPCError","httpStatus":400,"severity":"error","filePath":"packages/server/src/services/libsql.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 newLibsql = await db\n\t\t.insert(libsql)\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 (!newLibsql) {\n\t\tthrow new TRPCError({\n\t\t\tcode: \"BAD_REQUEST\",\n\t\t\tmessage: \"Error input: Inserting libsql database\",\n\t\t});\n\t}\n\n\treturn newLibsql;\n};\n\n// https://github.com/drizzle-team/drizzle-orm/discussions/1483#discussioncomment-7523881\nexport const findLibsqlById = async (libsqlId: string) => {\n\tconst result = await db.query.libsql.findFirst({\n\t\twhere: eq(libsql.libsqlId, libsqlId),\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},","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/packages/server/src/services/libsql.ts#L26-L62","documentation":"Thrown by createLibsql when the Drizzle insert into the libsql table with .returning() produces no row. Like its sibling BAD_REQUEST insert errors, it means the INSERT itself failed (constraint, schema mismatch, or DB error) — not that user input was malformed validation-wise.","triggerScenarios":"Calling createLibsql after the duplicate-name check passes, but the INSERT ... RETURNING into the libsql table returns empty — e.g. NOT NULL violation, enum mismatch on applicationStatus, or schema drift.","commonSituations":"Schema drift after upgrading Dokploy without running migrations, a missing default on a new column, or a DB connection that drops mid-insert.","solutions":["Check server logs for the Postgres error accompanying the failed insert","Run pending migrations / drizzle push so the libsql table matches the schema","Validate that required fields (appName, applicationStatus) have values before insert"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { const db = await createLibsql(input); } catch (e) { if (e.shape?.data?.code === 'BAD_REQUEST') { logServerError(e); /* DB-side, inspect logs */ } }","preventionTips":["Keep migrations in sync before creating resources","Monitor DB connectivity/health"],"tags":["database","drizzle-orm","libsql","insert"],"backgroundTag":"database-insert-returned-no-row","analyzedSha":"546686ea3587f12ec5652217dedd9f7960fb6d15","analyzedAt":"2026-08-27T05:18:58.095Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}