pulumi/pulumi · error

collect state migrations

Error message

collect state migrations: %w

What it means

State migrations registered by providers (for resource state upgrades) are collected in a locked closure during RegisterResource. If registration of pending state migrations fails, the error is wrapped as 'collect state migrations: %w'.

Solutions

  1. Upgrade or reinstall the provider plugin so migration metadata resolves
  2. Check the provider's plugin logs for the underlying failure during registration
  3. Pin a provider version known to support the state migrations for your stack

Example fix

pulumi plugin install resource myprov v2.1.0  # replace broken/missing plugin
Defensive patterns

Strategy: try-catch

Try / catch

if err := registerStateMigrations(key); err != nil {
    return nil, fmt.Errorf("collect state migrations: %w", err)
}

Prevention

When it happens

Trigger: RegisterResource where the resource's provider (or parent provider) supplies state migrations via GetStateMigrations/pendingStateMigrations and the collection closure returns an error (e.g. gRPC call to provider fails).

Common situations: Provider plugins implementing state migrations failing mid-handshake; provider version mismatch where migration metadata cannot be resolved; provider crash during registration.

Related errors


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

Appendix: source

Thrown at pkg/resource/deploy/source_eval.go:2557

		defer rm.pendingStateMigrationsLock.Unlock()

		if pending, ok := rm.pendingStateMigrations[pendingKey]; ok {
			delete(rm.pendingStateMigrations, pendingKey)
			stateMigrations = pending
		} else {
			stateMigrations, err = slice.MapError(req.StateMigrations, rm.wrapStateMigrationCallback)
			if err != nil {
				return err
			}
			// We only need to save this for remote calls
			if remote && len(stateMigrations) > 0 {
				rm.pendingStateMigrations[pendingKey] = stateMigrations
			}
		}
		return nil
	}()
	if err != nil {
		return nil, fmt.Errorf("collect state migrations: %w", err)
	}

	// We handle updating the providers map to include the providers field of the parent if
	// both the current resource and its parent is a component resource.
	func() {
		// Function exists to scope the lock
		rm.componentProvidersLock.Lock()
		defer rm.componentProvidersLock.Unlock()
		if parentsProviders, parentIsComponent := rm.componentProviders[parent]; !custom &&
			parent != "" && parentIsComponent {
			for k, v := range parentsProviders {
				if opts.Providers == nil {
					opts.Providers = map[string]string{}
				}
				if _, ok := opts.Providers[k]; !ok {
					opts.Providers[k] = v
				}
			}

View on GitHub (pinned to 793f7b2e16)