{"record":{"id":"ba55ecd26c885c44","repo":"Dokploy/dokploy","slug":"bad-request-ba55ec","errorCode":"BAD_REQUEST","errorMessage":"Server is required","messagePattern":"Server is required","errorType":"exception","errorClass":"TRPCError","httpStatus":400,"severity":"error","filePath":"packages/server/src/services/network.ts","lineNumber":90,"sourceCode":"\nconst findNetworksByServer = async (\n\torganizationId: string,\n\tserverId: string | null,\n) => {\n\treturn await db.query.network.findMany({\n\t\twhere: and(\n\t\t\teq(network.organizationId, organizationId),\n\t\t\tserverId ? eq(network.serverId, serverId) : isNull(network.serverId),\n\t\t),\n\t});\n};\n\nexport const findNetworksToSync = async (\n\torganizationId: string,\n\tserverId: string | null,\n) => {\n\tif (IS_CLOUD && !serverId) {\n\t\tthrow new TRPCError({\n\t\t\tcode: \"BAD_REQUEST\",\n\t\t\tmessage: \"Server is required\",\n\t\t});\n\t}\n\n\tconst docker = await getRemoteDocker(serverId);\n\tlet dockerNetworks: DockerNetworkInfo[] = [];\n\ttry {\n\t\tdockerNetworks = (await docker.listNetworks()) as DockerNetworkInfo[];\n\t} catch (error) {\n\t\tthrow new TRPCError({\n\t\t\tcode: \"BAD_REQUEST\",\n\t\t\tmessage:\n\t\t\t\terror instanceof Error\n\t\t\t\t\t? error.message\n\t\t\t\t\t: \"Failed to list Docker networks\",\n\t\t\tcause: error,\n\t\t});","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/packages/server/src/services/network.ts#L72-L108","documentation":"findNetworksToSync requires an explicit serverId when running the cloud edition (IS_CLOUD). On cloud, docker networks are per-server resources and there is no default/local docker, so serverId: null is rejected as BAD_REQUEST.","triggerScenarios":"Calling the network sync endpoint from the cloud UI/API without a server selected — e.g. serverId omitted from the request payload or null passed explicitly.","commonSituations":"Client built against self-hosted mode (where serverId is optional) deployed against the cloud version; UI state where no server is picked yet.","solutions":["Pass a valid serverId in the request","Ensure the server dropdown/selection is made before triggering network sync","Set the active server in client context before calling the API"],"exampleFix":"// before\nawait trpc.network.findNetworksToSync.query({ organizationId, serverId: null });\n// after\nawait trpc.network.findNetworksToSync.query({ organizationId, serverId: selectedServerId });","handlingStrategy":"validation","validationCode":"if (IS_CLOUD && !serverId) throw new Error(\"select a server before syncing networks\");","typeGuard":"const hasServer = (s: string | null): s is string => typeof s === \"string\" && s.length > 0;","tryCatchPattern":"try { await findNetworksToSync(orgId, serverId); } catch (e) { if (e instanceof TRPCError && e.message === \"Server is required\") promptServerSelection(); else throw e; }","preventionTips":["Gate cloud UI actions on an active server selection","Centralize a requireServerId() helper in clients"],"tags":["network","cloud","validation","server-id"],"backgroundTag":"missing-required-parameter","analyzedSha":"546686ea3587f12ec5652217dedd9f7960fb6d15","analyzedAt":"2026-08-27T05:18:58.095Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}