hasura/graphql-engine · error

operation failed: %w

Error message

operation failed: %w

What it means

Raised by `hasura deploy` (config v2 path) after the deploy finite state machine ends in the failedOperation state. The FSM wraps multi-step deploy operations (e.g. applying migrations); when a step fails, its error is stored in context.err and re-raised as 'operation failed'.

Source

Thrown at cli/commands/deploy.go:171

		ec:        opts.EC,
		logger:    opts.EC.Logger,
		err:       nil,
		withSeeds: opts.WithSeeds,

		noTransaction:           opts.NoTransaction,
		perMigrationTransaction: opts.PerMigrationTransaction,
	}

	if opts.EC.Config.Version <= cli.V2 {
		configV2FSM := newConfigV2DeployFSM()

		err := configV2FSM.SendEvent(applyMigrations, context)
		if err != nil {
			return errors.E(op, err)
		}

		if configV2FSM.Current == failedOperation {
			return errors.E(op, fmt.Errorf("operation failed: %w", context.err))
		}

		return nil
	}

	configV3FSM := newConfigV3DeployFSM()

	err := configV3FSM.SendEvent(applyInitialMetadata, context)
	if err != nil {
		return errors.E(op, err)
	}

	if configV3FSM.Current == failedOperation {
		return errors.E(op, fmt.Errorf("operation failed: %w", context.err))
	}

	return nil
}

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Inspect the wrapped context.err (run with debug/verbose logging) to identify the failing step and address it (connectivity, credentials, or the specific migration)
  2. Verify endpoint, admin secret, and server version compatibility for the target
  3. Fix or squash the offending migration, then re-run `hasura deploy`
  4. Ensure config.Version matches the project layout (v2 with migrations directory) you are deploying
Defensive patterns

Strategy: try-catch

Try / catch

if err := deployCmd.Run(); err != nil {
    // unwrap with errors.Unwrap / errors.As to reach the underlying migration error
    var inner error
    if errors.As(err, &inner) { log.Printf("deploy failed: %v", inner) }
}

Prevention

When it happens

Trigger: `hasura deploy` on a config Version-2 project where the applyMigrations event (or a prior FSM step) fails — e.g. unreachable Hasura endpoint, bad admin secret, malformed/incompatible migration files, or metadata inconsistency.

Common situations: CI deploy with wrong HASURA_GRAPHQL_ENDPOINT/ADMIN_SECRET env vars; migration chain containing an old migration that no longer applies cleanly against the current server version; network/DNS failure to the Hasura instance.

Related errors


AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28). Data as JSON: /api/errors/759754b8a4f9e363. Report an issue: GitHub.