{"record":{"id":"1f364b0403cd000d","repo":"different-ai/openwork","slug":"reserved-env-key","errorCode":"reserved_env_key","errorMessage":"Environment variable name is reserved for OpenWork internals: ${key}","messagePattern":"Environment variable name is reserved for OpenWork internals: (.+?)","errorType":"validation","errorClass":"InvalidEnvKeyError","httpStatus":400,"severity":"error","filePath":"apps/server/src/env-file.ts","lineNumber":206,"sourceCode":"    return run;\n  }\n\n  async list(): Promise<EnvRecord[]> {\n    await this.ensureLoaded();\n    return this.variables.slice();\n  }\n\n  async upsertMany(entries: EnvEntry[]): Promise<void> {\n    return this.enqueueMutation(async () => {\n      await this.ensureLoaded();\n      const now = Date.now();\n      const next = new Map(this.variables.map((entry) => [entry.key, entry] as const));\n      for (const entry of entries) {\n        if (!isValidEnvKey(entry.key)) {\n          throw new InvalidEnvKeyError(entry.key, \"invalid_env_key\");\n        }\n        if (isReservedEnvKey(entry.key)) {\n          throw new InvalidEnvKeyError(entry.key, \"reserved_env_key\");\n        }\n        next.set(entry.key, { key: entry.key, value: entry.value, updatedAt: now });\n      }\n      const nextVariables = Array.from(next.values()).sort((a, b) => a.key.localeCompare(b.key));\n      await writeStore(this.path, nextVariables);\n      this.variables = nextVariables;\n    });\n  }\n\n  async delete(key: string): Promise<boolean> {\n    return this.enqueueMutation(async () => {\n      await this.ensureLoaded();\n      const before = this.variables.length;\n      const nextVariables = this.variables.filter((entry) => entry.key !== key);\n      if (nextVariables.length === before) return false;\n      await writeStore(this.path, nextVariables);\n      this.variables = nextVariables;\n      return true;","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/server/src/env-file.ts#L188-L224","documentation":"Error thrown when a user attempts to set an environment variable whose name is reserved for OpenWork internals (e.g., names the server itself manages or injects, such as PORT, OPENWORK_* variables, or other protected keys). This guard prevents user-supplied values from overriding internal server configuration. Fix by choosing a non-reserved variable name; check the reserved-name list in env-file.ts to see which keys are protected.","triggerScenarios":"Attempting to upsert a key matching a reserved name (e.g. OPENWORK_* prefixed or other internal identifiers), typically to override agent/server behavior through the user env store.","commonSituations":"Users trying to override OpenWork's own configuration vars; automation scripts echoing internal keys back into the store; importing an env dump from a machine where internal vars were exported.","solutions":["Choose a non-reserved key name for your variable (avoid OPENWORK_* and other reserved prefixes)","If overriding an internal setting is needed, use the dedicated server configuration surface instead of the env store","Filter reserved keys out of imported env dumps before upserting"],"exampleFix":"// before\nawait envStore.upsertMany([{ key: \"OPENWORK_HOME\", value: \"/tmp/x\" }]);\n// after\nawait envStore.upsertMany([{ key: \"MY_OPENWORK_HOME\", value: \"/tmp/x\" }]);","handlingStrategy":"validation","validationCode":"if (entries.some(e => isReservedEnvKey(e.key))) throw new Error(\"reserved keys present\");","typeGuard":null,"tryCatchPattern":"try { await envStore.upsertMany(entries); } catch (e) { if (e instanceof InvalidEnvKeyError && e.code === \"reserved_env_key\") { /* pick another name */ } else throw e; }","preventionTips":["Maintain a shared reserved-key list client-side","Never upsert OPENWORK_* keys","Suggest alternative names in the UI"],"tags":["env-vars","reserved-names","validation"],"backgroundTag":"reserved-identifier","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}