pulumi/pulumi · error

updating environment definition: %w

Error message

updating environment definition: %w

What it means

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.

Source

Thrown at pkg/cmd/esc/cli/env.go:500

			}
			fmt.Fprintln(esc.stdout, "Change request submitted")
		}
		return diags, nil
	} else if draft != "" {
		changeRequestID := draft
		diags, err := esc.client.UpdateEnvironmentDraft(ctx, ref.orgName, ref.projectName, ref.envName, changeRequestID, yaml, tag) //nolint:lll
		if err != nil {
			return nil, fmt.Errorf("updating environment draft: %w", err)
		}
		if !client.DiagnosticsHaveErrors(diags) {
			fmt.Fprintln(esc.stdout, "Change request updated")
			fmt.Fprintf(esc.stdout, "Change request URL: %v\n", esc.changeRequestURL(ref, changeRequestID))
		}
		return diags, nil
	} else {
		diags, revision, err := esc.client.UpdateEnvironment(ctx, ref.orgName, ref.projectName, ref.envName, yaml, tag)
		if err != nil {
			return nil, fmt.Errorf("updating environment definition: %w", err)
		}
		if !client.DiagnosticsHaveErrors(diags) && envUpdateSuccessMessage != "" {
			fmt.Fprintf(esc.stdout, "%s (revision %d)\n", envUpdateSuccessMessage, revision)
		}
		return diags, nil
	}
}

View on GitHub (pinned to 793f7b2e16)

Solutions

  1. Read the wrapped inner error to find the API reason
  2. Confirm the environment exists: `esc env ls org/project`
  3. Verify write permissions on the environment
  4. Retry if the failure was transient (network/rate limit)

Example fix

// before
esc env set my-org/prj/env key value   # 404 not found
// after
esc env ls my-org            # find correct project/env
esc env set my-org/proj/env key value
Defensive patterns

Strategy: try-catch

Validate before calling

// Go: confirm the environment exists before direct update
_, err := client.GetEnvironment(ctx, ref.orgName, ref.projectName, ref.envName)
if err != nil {
    return fmt.Errorf("environment %s/%s/%s not found: %w", ref.orgName, ref.projectName, ref.envName, err)
}

Try / catch

// Go
_, err := updateEnvironment(ctx, ref, yaml, tag)
if err != nil && strings.Contains(err.Error(), "updating environment definition") {
    return fmt.Errorf("direct update failed; check the env exists and you have write access: %w", err)
}

Prevention

When it happens

Trigger: 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.

Common situations: Typo in org/project/env name; user lacks write access; environment was deleted by someone else; concurrency conflicts on the revision tag.

Related errors


AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31). Data as JSON: /api/errors/67307af8695d63ea. Report an issue: GitHub.