googleapis/mcp-toolbox · error

dialect invalid: must be one of "googlesql", or "postgresql"

Error message

dialect invalid: must be one of "googlesql", or "postgresql"

What it means

Thrown by Dialect.UnmarshalYAML in internal/sources/dialect.go when a configured dialect string is not one of the two supported values "googlesql" or "postgresql" (comparison is case-insensitive). Dialects are used by sources like BigQuery/Cloud SQL to select the SQL flavor; an unknown value makes the config invalid and initialization fails.

Source

Thrown at internal/sources/dialect.go:43

func (i *Dialect) String() string {
	if string(*i) != "" {
		return strings.ToLower(string(*i))
	}
	return "googlesql"
}

func (i *Dialect) UnmarshalYAML(ctx context.Context, unmarshal func(interface{}) error) error {
	var dialect string
	if err := unmarshal(&dialect); err != nil {
		return err
	}
	switch strings.ToLower(dialect) {
	case "googlesql", "postgresql":
		*i = Dialect(strings.ToLower(dialect))
		return nil
	default:
		return fmt.Errorf(`dialect invalid: must be one of "googlesql", or "postgresql"`)
	}
}

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Change the dialect value in the config to exactly "googlesql" or "postgresql" (any casing).
  2. Check the source's documentation for which dialects it supports before setting the field.
  3. Remove the dialect field entirely if the source doesn't require one, if optional.

Example fix

# before
dialect: mysql
# after
dialect: postgresql
Defensive patterns

Strategy: validation

Validate before calling

d := dialect.Dialect("")
allowed := map[string]bool{"googlesql": true, "postgresql": true}
if v := strings.TrimSpace(cfgDialect); v != "" && !allowed[strings.ToLower(v)] {
    return fmt.Errorf("dialect %q unsupported: use googlesql or postgresql", v)
}

Type guard

func isSupportedDialect(s string) bool {
    switch strings.ToLower(s) {
    case "googlesql", "postgresql":
        return true
    }
    return false
}

Try / catch

if err := yaml.Unmarshal(cfgBytes, &cfg); err != nil {
    if strings.Contains(err.Error(), "dialect invalid") {
        return fmt.Errorf("fix the dialect field in your config: must be googlesql or postgresql: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: A YAML/tool config sets a dialect field to any string other than googlesql/postgresql (e.g. "mysql", "standard", "bigquery", or a typo like "googlesq") and the config is unmarshaled.

Common situations: Copy-pasting a dialect name from another database's config, assuming other engines are supported, capitalization concerns (not an issue — it's lowercased), or leaving a placeholder value in the YAML.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05). Data as JSON: /api/errors/af9eb8b3898ed88a. Report an issue: GitHub.