pulumi/pulumi · error

Request to remove policy pack failed: %w

Error message

Request to remove policy pack failed: %w

What it means

Wraps errors from the DELETE call that removes all versions of a policy pack from the Pulumi organization (RemovePolicyPack).

Source

Thrown at pkg/backend/httpstate/client/client.go:2215

		RemovePolicyPack: &apitype.PolicyPackMetadata{
			Name:       policyPackName,
			VersionTag: versionTag,
		},
	}

	err := pc.restCall(ctx, http.MethodPatch, updatePolicyGroupPath(orgName, policyGroup), nil, req, nil)
	if err != nil {
		return fmt.Errorf("Request to disable policy pack failed: %w", err)
	}
	return nil
}

// RemovePolicyPack removes all versions of a `PolicyPack` from the Pulumi organization.
func (pc *Client) RemovePolicyPack(ctx context.Context, orgName string, policyPackName string) error {
	path := deletePolicyPackPath(orgName, policyPackName)
	err := pc.restCall(ctx, http.MethodDelete, path, nil, nil, nil)
	if err != nil {
		return fmt.Errorf("Request to remove policy pack failed: %w", err)
	}
	return nil
}

// RemovePolicyPackByVersion removes a specific version of a `PolicyPack` from
// the Pulumi organization.
func (pc *Client) RemovePolicyPackByVersion(ctx context.Context, orgName string,
	policyPackName string, versionTag string,
) error {
	path := deletePolicyPackVersionPath(orgName, policyPackName, versionTag)
	err := pc.restCall(ctx, http.MethodDelete, path, nil, nil, nil)
	if err != nil {
		return fmt.Errorf("Request to remove policy pack failed: %w", err)
	}
	return nil
}

// GetStackPolicyPacks gets the required policy packs currently applicable to the stack.

View on GitHub (pinned to 793f7b2e16)

Solutions

  1. Check the wrapped error's HTTP status
  2. Verify the policy pack still exists in the org
  3. Confirm your token has org admin/delete permissions
  4. Retry on transient network errors
Defensive patterns

Strategy: try-catch

Validate before calling

if orgName == "" || policyPackName == "" { return errors.New("org and policy pack name are required") }

Try / catch

if err := client.RemovePolicyPack(ctx, org, pack); err != nil {
	if strings.Contains(err.Error(), "404") { return nil } // already gone
	return fmt.Errorf("removing policy pack %s: %w", pack, err)
}

Prevention

When it happens

Trigger: Calling Client.RemovePolicyPack with a nonexistent org or policy pack name (404), missing delete permissions (403), or network/server failures.

Common situations: Deleting a pack that was already removed, typo'd pack name, token scoped to another org, or org admin enforcement preventing deletion.

Understand the failure class

Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.

Related errors


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