{"record":{"id":"a8974892a3dad50b","repo":"pulumi/pulumi","slug":"getting-environment-definition-w-a89748","errorCode":null,"errorMessage":"getting environment definition: %w","messagePattern":"getting environment definition: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/esc/cli/env_provider_common.go","lineNumber":183,"sourceCode":"\tenvVars []envVar,\n) error {\n\tvar def []byte\n\tvar tag string\n\tvar err error\n\tif draft != \"\" && draft != \"new\" {\n\t\tdef, tag, err = env.esc.client.GetEnvironmentDraft(ctx, ref.orgName, ref.projectName, ref.envName, draft)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"getting environment draft definition: %w\", err)\n\t\t}\n\t} else {\n\t\tdef, tag, _, err = env.esc.client.GetEnvironment(ctx, ref.orgName, ref.projectName, ref.envName, \"\", false)\n\t\tif err != nil {\n\t\t\tif client.IsNotFound(err) {\n\t\t\t\treturn fmt.Errorf(\n\t\t\t\t\t\"environment %s does not exist; pass --create to create it, or run `esc env init %s` first\",\n\t\t\t\t\tref.String(), ref.String())\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"getting environment definition: %w\", err)\n\t\t}\n\t}\n\n\tnewYAML, changed, err := mergeProviderIntoEnv(def, path, providerNode, envVars)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif !changed {\n\t\tfmt.Fprintf(env.esc.stdout, \"No changes to %s; already up to date.\\n\", ref.String())\n\t\treturn nil\n\t}\n\n\tdiags, err := env.esc.updateEnvironment(ctx, ref, draft, newYAML, tag, \"Provider updated.\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(diags) != 0 {\n\t\twerr := env.writeYAMLEnvironmentDiagnostics(env.esc.stderr, ref.projectName+\"/\"+ref.envName, newYAML, diags)","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/cmd/esc/cli/env_provider_common.go#L165-L201","documentation":"This wraps any error from GetEnvironment that is NOT a not-found condition: authentication failure, network errors, permission denied, or server-side errors. The not-found case is handled separately with a more specific message (see error 322).","triggerScenarios":"Calling applyProviderUpdate with an empty draft where GetEnvironment(ctx, org, project, env, \"\", false) fails with an error other than 404: invalid/expired token, 401/403 from Pulumi Cloud, timeouts, 5xx responses.","commonSituations":"Stale `esc login` credentials; lacking read access to the environment (different org, RBAC); corporate proxy blocking the API; Pulumi Cloud outage.","solutions":["Re-authenticate with `esc login` (or `pulumi login`) and retry.","Confirm your account has read access to org/project/environment.","Check network connectivity, proxy settings, and Pulumi Cloud status.","Verify the environment exists; if it genuinely doesn't, use --create (that yields the clearer not-found message)."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if _, err := escClient.GetUser(ctx); err != nil {\n    return fmt.Errorf(\"ESC authentication invalid, run `esc login` first: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"err := applyProviderUpdate(ctx, env, ref, \"\", path, node, vars)\nif err != nil && strings.Contains(err.Error(), \"getting environment definition\") {\n    if isTransient(err) { // network/5xx\n        time.Sleep(backoff)\n        err = applyProviderUpdate(ctx, env, ref, \"\", path, node, vars)\n    }\n}","preventionTips":["Refresh credentials before CI runs (esc login / service token).","Check org/RBAC permissions for the target environment.","Retry with backoff on transient network errors only."],"tags":["esc","api","network","authentication"],"backgroundTag":"api-request-failed","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}