{"record":{"id":"efde29fb9ce2e1c4","repo":"paperclipai/paperclip","slug":"daytona-sandbox-environments-require-an-api-key-in","errorCode":null,"errorMessage":"Daytona sandbox environments require an API key in config or DAYTONA_API_KEY.","messagePattern":"Daytona sandbox environments require an API key in config or DAYTONA_API_KEY\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"packages/plugins/sandbox-providers/daytona/src/plugin.ts","lineNumber":248,"sourceCode":"    // Daytona session per lease and dispatches every command into it. The flag\n    // stays default off until a live leak soak passes.\n    useSessions: raw.useSessions === true,\n    // Log-stream opt-in. Default OFF. When off, the session dispatch polls the\n    // exit code every 50 ms and then reads the logs one time. When on, the\n    // dispatch streams stdout and stderr from the callback log form and reads\n    // the exit code one time after the stream ends. The flag stays default off\n    // until a live soak passes.\n    useLogStream: raw.useLogStream === true,\n  };\n}\n\nfunction resolveApiKey(config: DaytonaDriverConfig): string {\n  if (config.apiKey) {\n    return config.apiKey;\n  }\n  const envApiKey = process.env.DAYTONA_API_KEY?.trim() ?? \"\";\n  if (!envApiKey) {\n    throw new Error(\"Daytona sandbox environments require an API key in config or DAYTONA_API_KEY.\");\n  }\n  return envApiKey;\n}\n\nfunction createDaytonaClient(config: DaytonaDriverConfig): Daytona {\n  const clientConfig: DaytonaConfig = {\n    apiKey: resolveApiKey(config),\n  };\n  if (config.apiUrl) clientConfig.apiUrl = config.apiUrl;\n  if (config.target) clientConfig.target = config.target;\n  return new Daytona(clientConfig);\n}\n\nfunction buildResources(config: DaytonaDriverConfig): Resources | undefined {\n  if (config.cpu == null && config.memory == null && config.disk == null && config.gpu == null) {\n    return undefined;\n  }\n  return {","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/packages/plugins/sandbox-providers/daytona/src/plugin.ts#L230-L266","documentation":"Thrown by resolveApiKey when neither the driver config's apiKey field nor the DAYTONA_API_KEY environment variable provides a non-empty API key. Every Daytona client construction requires a resolved key, so absence fails immediately at client creation.","triggerScenarios":"createDaytonaClient is called (during sandbox creation, probe, or interactive setup) with config.apiKey falsy AND process.env.DAYTONA_API_KEY empty/undefined/whitespace-only.","commonSituations":"First-time setup without setting DAYTONA_API_KEY; .env file not loaded in the process; the environment plugin config omits apiKey; CI runner missing the secret; the key was set in a different shell than the one running the server.","solutions":["Set DAYTONA_API_KEY in the environment of the process running Paperclip (export DAYTONA_API_KEY=..., or add to .env / CI secret).","Alternatively, provide apiKey in the Daytona driver config passed to the plugin.","Verify the key is non-empty after trimming (no whitespace-only value).","Restart the server/worker after setting the env var so it is read at startup."],"exampleFix":"# before: no key configured\n# after: export before starting the server\nexport DAYTONA_API_KEY=dts_yourkey\npnpm dev","handlingStrategy":"validation","validationCode":"function hasDaytonaApiKey(config: { apiKey?: string | null }): boolean {\n  return Boolean(config.apiKey || (process.env.DAYTONA_API_KEY ?? '').trim());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set DAYTONA_API_KEY in the process environment before starting the server/worker.","Alternatively, configure apiKey in the Daytona driver config.","Verify CI/runtime secrets inject the key into the running process."],"tags":["daytona","config","auth","api-key","env"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}