{"record":{"id":"661fb61939b92462","repo":"vercel/ai","slug":"acp-runtime-environment-key-json-stringify-key-661fb6","errorCode":null,"errorMessage":"ACP runtime environment key ${JSON.stringify(key)} cannot be configured in both forwardEnv and env.","messagePattern":"ACP runtime environment key (.+?) cannot be configured in both forwardEnv and env\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/harness-acp/src/v1/implementation.ts","lineNumber":93,"sourceCode":"      `ACP executable must be a bare command name without a path; received ${JSON.stringify(implementation.executable)}.`,\n    );\n  }\n\n  validateForwardEnvironment({ forwardEnv: implementation.forwardEnv });\n  validateForwardEnvironment({ forwardEnv: implementation.credentialEnv });\n  validateEnvironment({ env: implementation.env });\n  const forwardedKeys = new Set(implementation.forwardEnv ?? []);\n  const credentialKeys = new Set(implementation.credentialEnv ?? []);\n  for (const key of credentialKeys) {\n    if (forwardedKeys.has(key)) {\n      throw new Error(\n        `ACP runtime environment key ${JSON.stringify(key)} cannot be configured in both forwardEnv and credentialEnv.`,\n      );\n    }\n  }\n  for (const key of Object.keys(implementation.env ?? {})) {\n    if (forwardedKeys.has(key)) {\n      throw new Error(\n        `ACP runtime environment key ${JSON.stringify(key)} cannot be configured in both forwardEnv and env.`,\n      );\n    }\n    if (credentialKeys.has(key)) {\n      throw new Error(\n        `ACP runtime environment key ${JSON.stringify(key)} cannot be configured in both credentialEnv and env.`,\n      );\n    }\n  }\n}\n\nexport function createImplementationManifest({\n  implementation,\n}: {\n  implementation: ACPImplementation;\n}): string | undefined {\n  const { source } = implementation;\n  if (source.type === 'install-command') return undefined;","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/harness-acp/src/v1/implementation.ts#L75-L111","documentation":"A key may not appear in both forwardEnv (pass-through of existing host variables) and env (static values set for the subprocess). The static value in env would silently conflict with the forwarded host value, so the overlap is rejected at construction time.","triggerScenarios":"createACPV1 where a key in implementation.env is also listed in implementation.forwardEnv, e.g. env: {NODE_ENV:'production'} plus forwardEnv:['NODE_ENV'].","commonSituations":"Setting defaults in env while also listing the same var in forwardEnv, merging base config with per-environment overrides, or templated configs accumulating both lists over time.","solutions":["Delete the key from forwardEnv if the fixed value in env should win.","Delete it from env if the host value should be forwarded instead.","Prefer credentialEnv for secret vars rather than duplicating across env/forwardEnv."],"exampleFix":"// before\ncreateACPV1({ env: { DEBUG: 'acp:*' }, forwardEnv: ['DEBUG'] });\n// after\ncreateACPV1({ env: { DEBUG: 'acp:*' } });","handlingStrategy":"validation","validationCode":"const forwarded = new Set(implementation.forwardEnv ?? []);\nconst dup = Object.keys(implementation.env ?? {}).filter(k => forwarded.has(k));\nif (dup.length > 0) throw new Error(`Keys in both forwardEnv and env: ${dup.join(', ')}`);","typeGuard":"function envAndForwardAreDisjoint(env, forwardEnv) {\n  const fw = new Set(forwardEnv ?? []);\n  return Object.keys(env ?? {}).every(k => !fw.has(k));\n}","tryCatchPattern":"try {\n  const impl = createACPV1(settings);\n} catch (err) {\n  if (err instanceof Error && err.message.includes('both forwardEnv and env')) {\n    console.error('Pick one source of truth: delete the key from forwardEnv or from env');\n  }\n  throw err;\n}","preventionTips":["Decide per variable: static value (env) OR host pass-through (forwardEnv), never both","When merging config layers, remove overridden keys from forwardEnv","Lint settings objects for env/forwardEnv overlaps"],"tags":["configuration","environment","validation"],"backgroundTag":"invalid-config-value","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}