{"record":{"id":"9a2887a15766f68b","repo":"serverless/serverless","slug":"invoke-local-unsupported-env-variable","errorCode":"INVOKE_LOCAL_UNSUPPORTED_ENV_VARIABLE","errorMessage":"Unsupported environment variable format: ${inspect(value)}","messagePattern":"Unsupported environment variable format: (.+?)","errorType":"validation","errorClass":"ServerlessError","httpStatus":null,"severity":"error","filePath":"packages/serverless/lib/plugins/aws/invoke-local/index.js","lineNumber":285,"sourceCode":"  }\n\n  async resolveConfiguredEnvVars(configuredEnvVars) {\n    await Promise.all(\n      Object.entries(configuredEnvVars).map(async ([name, value]) => {\n        if (!_.isObject(value)) return\n        try {\n          if (value['Fn::ImportValue']) {\n            configuredEnvVars[name] = await resolveCfImportValue(\n              this.provider,\n              value['Fn::ImportValue'],\n            )\n          } else if (value.Ref) {\n            configuredEnvVars[name] = await resolveCfRefValue(\n              this.provider,\n              value.Ref,\n            )\n          } else {\n            throw new ServerlessError(\n              `Unsupported environment variable format: ${inspect(value)}`,\n              'INVOKE_LOCAL_UNSUPPORTED_ENV_VARIABLE',\n            )\n          }\n        } catch (error) {\n          throw new ServerlessError(\n            `Could not resolve \"${name}\" environment variable: ${error.message}`,\n            'INVOKE_LOCAL_INVALID_ENV_VARIABLE',\n          )\n        }\n      }),\n    )\n\n    return configuredEnvVars\n  }\n\n  async loadEnvVars() {\n    const lambdaName = this.options.functionObj.name","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/serverless/serverless/blob/b9d7ea51c8cce57cff1207964b9b71123673081f/packages/serverless/lib/plugins/aws/invoke-local/index.js#L267-L303","documentation":"Thrown by invoke-local's environment resolver when an env-var value is an object (a CloudFormation intrinsic) but uses a key other than Fn::ImportValue or Ref. The local resolver only knows those two intrinsics; anything else (Fn::Sub, Fn::Join, Fn::GetAtt, etc.) is unsupported for local invocation.","triggerScenarios":"Setting provider.environment or function.environment entries to `{ 'Fn::Sub': '...' }`, `{ 'Fn::Join': [...] }`, `{ 'Fn::GetAtt': [...] }`, or any intrinsic besides ImportValue/Ref, then running `sls invoke local`.","commonSituations":"Using Fn::Sub/Fn::Join in environment values (valid at deploy time, but the local invoker cannot resolve them); migrating config that relied on intrinsic composition.","solutions":["Replace the unsupported intrinsic with Fn::ImportValue or Ref if the underlying value can be expressed that way.","Use a literal string for the value when invoking locally.","Resolve the composed value out-of-band and pass it via a local-only environment file/variable."],"exampleFix":"# before\nenvironment:\n  TOPIC_ARN:\n    Fn::Sub: 'arn:aws:sns:${AWS::Region}:${AWS::AccountId}:my-topic'\n# after (resolvable locally)\nenvironment:\n  TOPIC_ARN:\n    Ref: MyTopicParameter","handlingStrategy":"type-guard","validationCode":"const SUPPORTED = ['Fn::ImportValue', 'Ref']\nfunction isResolvableEnvValue(v) {\n  if (v == null || typeof v !== 'object') return true\n  return SUPPORTED.some((k) => k in v)\n}\nfor (const [k, v] of Object.entries(mergedEnv)) {\n  if (!isResolvableEnvValue(v)) throw new Error(`env ${k} uses an unsupported intrinsic for local invoke`)\n}","typeGuard":"function isLocallyResolvableIntrinsic(v) {\n  return v == null || typeof v !== 'object' || 'Fn::ImportValue' in v || 'Ref' in v\n}","tryCatchPattern":null,"preventionTips":["Restrict environment intrinsics to Fn::ImportValue/Ref when local invoke is needed.","Move complex intrinsic composition out of environment values and into resolved parameters.","Maintain a local-only env override file for values that cannot be expressed as Ref/ImportValue."],"tags":["invoke-local","environment","cloudformation","intrinsic"],"backgroundTag":null,"analyzedSha":"b9d7ea51c8cce57cff1207964b9b71123673081f","analyzedAt":"2026-08-13T04:14:40.386Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}