{"record":{"id":"a444291c7b46b18c","repo":"paperclipai/paperclip","slug":"createos-requires-an-api-key-in-the-environment-config-or","errorCode":null,"errorMessage":"CreateOS requires an API key in the environment config or CREATEOS_API_KEY.","messagePattern":"CreateOS requires an API key in the environment config or CREATEOS_API_KEY\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/plugins/sandbox-providers/createos/src/config.ts","lineNumber":58,"sourceCode":"  }\n  return {\n    apiUrl: url.origin,\n    apiKey: text(\"apiKey\"),\n    shape,\n    rootfs: text(\"rootfs\"),\n    region: text(\"region\"),\n    timeoutMs,\n    reuseLease: raw.reuseLease === true,\n  };\n}\n\nexport function resolveApiKey(config: CreateosConfig): string {\n  if (!config.apiKey && config.apiUrl !== \"https://api.sb.createos.sh\") {\n    throw new Error(\"Custom CreateOS API endpoints require an explicit environment API key; the host fallback is only available for https://api.sb.createos.sh.\");\n  }\n  const key = config.apiKey ?? process.env.CREATEOS_API_KEY?.trim();\n  if (!key || /[\\r\\n\\0]/.test(key)) {\n    throw new Error(\"CreateOS requires an API key in the environment config or CREATEOS_API_KEY.\");\n  }\n  return key;\n}\n","sourceCodeStart":40,"sourceCodeEnd":62,"githubUrl":"https://github.com/paperclipai/paperclip/blob/3f1d897a7c018d76563a21c6e39c3c9b03933622/packages/plugins/sandbox-providers/createos/src/config.ts#L40-L62","documentation":"resolveApiKey resolves the API key from the environment config or the CREATEOS_API_KEY environment variable and rejects empty keys and keys containing CR, LF, or NUL. A missing key means the plugin cannot authenticate any CreateOS request, so it fails fast before making network calls.","triggerScenarios":"Calling resolveApiKey (via the plugin constructor or account method) when both config.apiKey and process.env.CREATEOS_API_KEY are unset/empty/whitespace, or the resolved key contains a newline, carriage return, or NUL character.","commonSituations":"CREATEOS_API_KEY not exported in the shell/CI job or container; key pasted from a file with a trailing newline; key set to empty string in a .env file; running in an environment where the env var was not mounted.","solutions":["Set CREATEOS_API_KEY in the process environment (export CREATEOS_API_KEY=... or add to the CI/secret store) and restart the process.","Or set apiKey explicitly in the CreateOS environment config.","Trim the key value and remove embedded newlines/whitespace from however it is stored.","Verify the variable name is exactly CREATEOS_API_KEY (no typos, no workspace-local .env being ignored)."],"exampleFix":"// before\nconst key = process.env.CREATEOS_API_KEY; // undefined in CI\n// after\nexport CREATEOS_API_KEY=\"ck_live_...\" && pnpm dev","handlingStrategy":"try-catch","validationCode":"const key = cfg.apiKey ?? process.env.CREATEOS_API_KEY?.trim();\nif (!key || /[\\r\\n\\0]/.test(key)) throw new Error('CREATEOS_API_KEY must be set, trimmed, and free of line breaks');","typeGuard":null,"tryCatchPattern":"try {\n  const plugin = new CreateosPlugin(cfg);\n} catch (e) {\n  if (e.message.includes('CreateOS requires an API key')) {\n    throw new Error('Set CREATEOS_API_KEY in the environment or apiKey in the config: ' + e.message);\n  }\n  throw e;\n}","preventionTips":["Assert the secret is present at process startup before spawning work","Trim keys when reading from files or secret stores","Use exact variable name CREATEOS_API_KEY and verify it in CI logs (never print the value)"],"tags":["api-key","env-var","authentication","credentials"],"backgroundTag":"missing-api-key","analyzedSha":"3f1d897a7c018d76563a21c6e39c3c9b03933622","analyzedAt":"2026-09-18T08:03:59.046Z","contentChangedAt":"2026-09-18T08:03:59.046Z","schemaVersion":2},"datasetVersion":"2026-09-22T11:17:16.035Z"}