{"record":{"id":"7c23e2977431f11f","repo":"serverless/serverless","slug":"invoke-local-invalid-env-variable","errorCode":"INVOKE_LOCAL_INVALID_ENV_VARIABLE","errorMessage":"Could not resolve \"${name}\" environment variable: ${error.message}","messagePattern":"Could not resolve \"(.+?)\" environment variable: (.+?)","errorType":"exception","errorClass":"ServerlessError","httpStatus":null,"severity":"error","filePath":"packages/serverless/lib/plugins/aws/invoke-local/index.js","lineNumber":291,"sourceCode":"        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\n    const memorySize =\n      Number(this.options.functionObj.memorySize) ||\n      Number(this.serverless.service.provider.memorySize) ||\n      1024\n\n    const lambdaDefaultEnvVars = {","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/serverless/serverless/blob/b9d7ea51c8cce57cff1207964b9b71123673081f/packages/serverless/lib/plugins/aws/invoke-local/index.js#L273-L309","documentation":"Error \"Could not resolve \"${name}\" environment variable: ${error.message}\" thrown in serverless/serverless.","triggerScenarios":"Thrown at packages/serverless/lib/plugins/aws/invoke-local/index.js:291 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Define the named environment variable in your shell or in the provider.environment section of serverless.yml before running invoke local.","Check for typos in the variable name referenced by your serverless.yml variable syntax."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b9d7ea51c8cce57cff1207964b9b71123673081f","analyzedAt":"2026-08-13T04:14:40.386Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}