{"record":{"id":"7fb41549a82c0ebc","repo":"pulumi/pulumi","slug":"gathering-environment-metadata-w","errorCode":null,"errorMessage":"gathering environment metadata: %w","messagePattern":"gathering environment metadata: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/pulumi/operations/destroy.go","lineNumber":269,"sourceCode":"\n\t\t\tif err := plugin.ValidatePulumiVersionRange(proj.RequiredPulumiVersion, version.Version); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tgetConfig := config.GetStackConfiguration\n\t\t\tif stackName != \"\" {\n\t\t\t\t// `pulumi destroy --stack <stack>` can be run outside of the project directory.\n\t\t\t\t// The config may be missing, fallback on the latest configuration in the backend.\n\t\t\t\tgetConfig = config.GetStackConfigurationOrLatest\n\t\t\t}\n\t\t\tcfg, sm, err := getConfig(ctx, cmdutil.Diag(), ssml, s, proj, configFile, envOverrides)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"getting stack configuration: %w\", err)\n\t\t\t}\n\n\t\t\tm, err := metadata.GetUpdateMetadata(message, root, execKind, execAgent, false, cfg, cmd.Flags())\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"gathering environment metadata: %w\", err)\n\t\t\t}\n\t\t\tcmdutil.SetStringSpanAttributes(ctx, m.Environment)\n\n\t\t\tdecrypter := sm.Decrypter()\n\t\t\tencrypter := sm.Encrypter()\n\n\t\t\tstackName := s.Ref().Name().String()\n\t\t\t// Skip config validation when the program is not being run (the default for destroy),\n\t\t\t// or when explicitly requested via --skip-config-validation. This allows stacks with\n\t\t\t// missing or invalid config to be destroyed in scenarios such as ephemeral PR environments\n\t\t\t// where config may diverge between branches.\n\t\t\tif runProgram && !skipConfigValidation {\n\t\t\t\t// Running the program: validate the stack config (and apply project defaults).\n\t\t\t\tconfigError := pkgWorkspace.ValidateStackConfigAndApplyProjectConfig(\n\t\t\t\t\tctx,\n\t\t\t\t\tstackName,\n\t\t\t\t\tproj,\n\t\t\t\t\tcfg.Environment,","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/cmd/pulumi/operations/destroy.go#L251-L287","documentation":"`pulumi destroy` failed while building the update metadata via metadata.GetUpdateMetadata. This collects environment information (execKind, execAgent, flags) and can fail when the environment or flags can't be processed. The underlying cause is wrapped.","triggerScenarios":"metadata.GetUpdateMetadata(message, root, execKind, execAgent, false, cfg, cmd.Flags()) returns an error during destroy startup.","commonSituations":"Odd exec-agent environments (CI wrappers, shells) producing unparseable environment metadata; corrupted command flags; environment variables Pulumi expects to interpret being malformed.","solutions":["Read the wrapped cause and fix the offending environment variable or flag","Retry the command from a plain shell/CI step without wrappers","Update the Pulumi CLI in case of an environment-detection bug","File an issue with the wrapped error if the cause is unclear"],"exampleFix":"// before\nPULUMI_EXEC_AGENT=\"not-a-valid-agent\" pulumi destroy\n// after\npulumi destroy  # run in a normal shell environment","handlingStrategy":"try-catch","validationCode":"// unset odd PULUMI_* exec-agent env vars before invoking: for v in $(env | grep -o '^PULUMI_[A-Z_]*'); do unset $v; done","typeGuard":null,"tryCatchPattern":"try { await pulumi.destroy(); } catch (e) { if (/gathering environment metadata/.test(e.message)) { /* retry in clean shell; report bug with wrapped cause */ } else throw e; }","preventionTips":["Run CLI from a plain shell/CI step without wrappers","Keep the CLI up to date","Avoid overriding internal PULUMI_* environment variables"],"tags":["cli","metadata","destroy"],"backgroundTag":"metadata-collection-failed","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}