ory/hydra · error

invalid autocommit flag %q

Error message

invalid autocommit flag %q

What it means

The migration filename grammar allows an optional single .autocommit marker. parseMigrationFilename throws this error (oryx/popx/match.go:85) when the autocommit capture group contains something other than ".autocommit" or empty. In practice the regex mostly constrains this, so the error fires when a filename places an unexpected token in the autocommit position.

Source

Thrown at oryx/popx/match.go:86

		switch dbType {
		case dbal.DriverYugabyteDB, "yugabytedb":
			dbType = dbal.DriverYugabyteDB
		default:
			dbType = pop.CanonicalDialect(dbType)
		}
		if dbType != dbal.DriverYugabyteDB && !pop.DialectSupported(dbType) {
			return nil, errors.Wrapf(errUnsupportedMigrationDialect, "%s", dbType)
		}
	}

	if m[typeIdx] == "fizz" && dbType != "all" {
		return nil, errors.Errorf("invalid database type %q, expected \"all\" because fizz is database type independent", dbType)
	}

	if m[autocommitIdx] == ".autocommit" {
		autocommit = true
	} else if m[autocommitIdx] != "" {
		return nil, errors.Errorf("invalid autocommit flag %q", m[autocommitIdx])
	}

	return &match{
		Version:    m[versionIdx],
		Name:       m[nameIdx],
		DBType:     dbType,
		Autocommit: autocommit,
		Direction:  m[directionIdx],
		Type:       m[typeIdx],
	}, nil
}

View on GitHub (pinned to 4174065ffb)

Solutions

  1. Rename the file so the optional flag is exactly .autocommit (e.g. 20210101000000_name.all.autocommit.up.sql)
  2. Remove the unsupported token from the filename entirely if autocommit behavior is not needed
  3. Check the regex MigrationFileRegexp in oryx/popx/match.go to confirm the accepted filename shape

Example fix

// before
20210101000000_name.all.nocommit.up.sql
// after
20210101000000_name.all.autocommit.up.sql
Defensive patterns

Strategy: validation

Validate before calling

const pattern = `^(\d+)_([^.]+)(\.[a-z0-9]+)?(\.autocommit)?\.(up|down)\.(sql)$`
var re = regexp.MustCompile(pattern)
// ensure the only optional flag token is .autocommit
if m := re.FindStringSubmatch(filename); m != nil && m[4] != "" && m[4] != ".autocommit" {
    return fmt.Errorf("invalid autocommit flag in %q", filename)
}

Try / catch

if _, err := parseMigrationFilename(name); err != nil {
    if strings.Contains(err.Error(), "invalid autocommit flag") {
        return fmt.Errorf("rename %s: only .autocommit is a valid flag", name)
    }
    return err
}

Prevention

When it happens

Trigger: A migration filename where the 4th capture group (between the optional dialect segment and .up/.down) is a non-empty string other than .autocommit — e.g. a stray suffix like .nocommit or a misplaced .autocommit within the name segment.

Common situations: Hand-edited filenames adding unknown flags; copy-paste mistakes duplicating or misspelling .autocommit; tooling that inserts build metadata into the filename.

Related errors


AI-assisted analysis of ory/hydra@4174065ffb (2026-09-03). Data as JSON: /api/errors/ec4b84a22e964954. Report an issue: GitHub.