hasura/graphql-engine · error

cannot fetch migrate status: %w

Error message

cannot fetch migrate status: %w

What it means

RunOnSource wraps the result of executeStatus: after successfully creating the migrate driver, querying migration status (hasuractl status) against the database failed. This is a database-side or migrations-catalog problem, not metadata export.

Source

Thrown at cli/commands/migrate_status.go:130

	}
)

func (o *MigrateStatusOptions) RunOnSource() (*migrate.Status, error) {
	var op errors.Op = "commands.MigrateStatusOptions.RunOnSource"

	if o.EC.Config.Version <= cli.V2 {
		o.Source.Name = ""
		o.Source.Kind = hasura.SourceKindPG
	}

	migrateDrv, err := migrate.NewMigrate(o.EC, true, o.Source.Name, o.Source.Kind)
	if err != nil {
		return nil, errors.E(op, err)
	}

	status, err := executeStatus(migrateDrv)
	if err != nil {
		return nil, errors.E(op, fmt.Errorf("cannot fetch migrate status: %w", err))
	}

	return status, nil
}

func printStatus(statusOpts StatusOptions) *bytes.Buffer {
	out := new(tabwriter.Writer)
	buf := &bytes.Buffer{}
	out.Init(buf, 0, 8, 2, ' ', 0)
	w := util.NewPrefixWriter(out)

	for source, status := range statusOpts {
		if source.Name != "" {
			w.Write(util.LEVEL_0, fmt.Sprintf("\nDatabase: %s\n", source.Name))
		}

		w.Write(util.LEVEL_0, "VERSION\tNAME\tSOURCE STATUS\tDATABASE STATUS\n")

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Re-run the status command (transient connection drops are common)
  2. Verify the CLI's DB user can read hdb_catalog (or information_schema) on the target database
  3. Check database logs for the failed query around the time of the error
  4. If state is corrupted, use 'hasura migrate apply' to reconcile and retry status
Defensive patterns

Strategy: retry

Validate before calling

// ensure the target DB accepts queries before status
db, err := sql.Open("pgx", dbURL)
if err != nil { return err }
defer db.Close()
if err := db.Ping(); err != nil { return fmt.Errorf("db not ready: %w", err) }

Try / catch

Retry with backoff on this error (transient drops/failovers are common); after N retries, unwrap and inspect whether the cause is permissions on hdb_catalog vs connectivity.

Prevention

When it happens

Trigger: Calling RunOnSource (migrate status / status APIs) where executeStatus errors: cannot query the hdb_catalog schema migrations state, DB connection dropped mid-query, or an unexpected response from the status command.

Common situations: Database restarted/failover during the query, permissions revoked on hdb_catalog, migrations state table corrupted, or proxy timeouts killing long status queries.

Related errors


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