{"record":{"id":"67307af8695d63ea","repo":"pulumi/pulumi","slug":"updating-environment-definition-w","errorCode":null,"errorMessage":"updating environment definition: %w","messagePattern":"updating environment definition: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/esc/cli/env.go","lineNumber":500,"sourceCode":"\t\t\t}\n\t\t\tfmt.Fprintln(esc.stdout, \"Change request submitted\")\n\t\t}\n\t\treturn diags, nil\n\t} else if draft != \"\" {\n\t\tchangeRequestID := draft\n\t\tdiags, err := esc.client.UpdateEnvironmentDraft(ctx, ref.orgName, ref.projectName, ref.envName, changeRequestID, yaml, tag) //nolint:lll\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"updating environment draft: %w\", err)\n\t\t}\n\t\tif !client.DiagnosticsHaveErrors(diags) {\n\t\t\tfmt.Fprintln(esc.stdout, \"Change request updated\")\n\t\t\tfmt.Fprintf(esc.stdout, \"Change request URL: %v\\n\", esc.changeRequestURL(ref, changeRequestID))\n\t\t}\n\t\treturn diags, nil\n\t} else {\n\t\tdiags, revision, err := esc.client.UpdateEnvironment(ctx, ref.orgName, ref.projectName, ref.envName, yaml, tag)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"updating environment definition: %w\", err)\n\t\t}\n\t\tif !client.DiagnosticsHaveErrors(diags) && envUpdateSuccessMessage != \"\" {\n\t\t\tfmt.Fprintf(esc.stdout, \"%s (revision %d)\\n\", envUpdateSuccessMessage, revision)\n\t\t}\n\t\treturn diags, nil\n\t}\n}\n","sourceCodeStart":482,"sourceCodeEnd":508,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/cmd/esc/cli/env.go#L482-L508","documentation":"updateEnvironment wraps errors from client.UpdateEnvironment with this message in the direct-update path (no change request/draft). It means the environment definition update API call failed and no new revision was written.","triggerScenarios":"Running `esc env set`/`esc env rm` style updates without a change-request flow, and UpdateEnvironment returns an error — nonexistent environment or project, permission denied, version tag conflict, or network/429 errors.","commonSituations":"Typo in org/project/env name; user lacks write access; environment was deleted by someone else; concurrency conflicts on the revision tag.","solutions":["Read the wrapped inner error to find the API reason","Confirm the environment exists: `esc env ls org/project`","Verify write permissions on the environment","Retry if the failure was transient (network/rate limit)"],"exampleFix":"// before\nesc env set my-org/prj/env key value   # 404 not found\n// after\nesc env ls my-org            # find correct project/env\nesc env set my-org/proj/env key value","handlingStrategy":"try-catch","validationCode":"// Go: confirm the environment exists before direct update\n_, err := client.GetEnvironment(ctx, ref.orgName, ref.projectName, ref.envName)\nif err != nil {\n    return fmt.Errorf(\"environment %s/%s/%s not found: %w\", ref.orgName, ref.projectName, ref.envName, err)\n}","typeGuard":null,"tryCatchPattern":"// Go\n_, err := updateEnvironment(ctx, ref, yaml, tag)\nif err != nil && strings.Contains(err.Error(), \"updating environment definition\") {\n    return fmt.Errorf(\"direct update failed; check the env exists and you have write access: %w\", err)\n}","preventionTips":["List environments first (`esc env ls org/project`) to verify names","Ensure your account has write access to the environment","Handle 404/403 distinctly before retrying"],"tags":["cli","api","environment"],"backgroundTag":"api-call-failed","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}