{"record":{"id":"04d460cb23dc8700","repo":"paperclipai/paperclip","slug":"failed-to-create-environment","errorCode":null,"errorMessage":"Failed to create environment","messagePattern":"Failed to create environment","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/src/services/environments.ts","lineNumber":1041,"sourceCode":"          config: input.config ?? {},\n          envVars: (input as CreateEnvironment & { envVars?: Record<string, unknown> }).envVars ?? {},\n          metadata: input.metadata ?? null,\n          createdAt: now,\n          updatedAt: now,\n        })\n        .returning()\n        .then((rows) => rows[0] ?? null)\n        .catch((error) => {\n          if (hasConstraintName(error, \"environments_name_idx\")) {\n            throw conflict(`An environment named \"${input.name}\" already exists for this instance.`);\n          }\n          if (hasConstraintName(error, \"environments_local_driver_idx\")) {\n            throw conflict(\"A local environment already exists for this instance.\");\n          }\n          throw error;\n        });\n      if (!row) {\n        throw new Error(\"Failed to create environment\");\n      }\n      return toEnvironment(row);\n    },\n\n    update: async (\n      id: string,\n      patch: UpdateEnvironment,\n      options?: { db?: EnvironmentWriteDb },\n    ): Promise<Environment | null> => {\n      const writeDb = options?.db ?? db;\n      const values: Partial<typeof environments.$inferInsert> = {\n        updatedAt: new Date(),\n      };\n      if (patch.name !== undefined) values.name = patch.name;\n      if (patch.description !== undefined) values.description = patch.description ?? null;\n      if (patch.driver !== undefined) values.driver = patch.driver;\n      if (patch.status !== undefined) values.status = patch.status;\n      if (patch.config !== undefined) values.config = patch.config;","sourceCodeStart":1023,"sourceCodeEnd":1059,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/server/src/services/environments.ts#L1023-L1059","documentation":"Generic guard in environment create: the INSERT ... RETURNING produced no row for reasons other than the mapped constraint conflicts (name uniqueness and local-driver uniqueness are handled explicitly above). Treats environment creation as failed rather than returning null.","triggerScenarios":"Thrown at server/src/services/environments.ts:1041 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check server logs for the environment creation failure and fix the reported cause (config, driver, quota)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}