hasura/graphql-engine · error · errDatabaseNotFound
%w: error determining database kind for '%s', check if datab
Error message
%w: error determining database kind for '%s', check if database exists on hasura
What it means
The metadata export succeeded but the requested source name was not found in the returned metadata (sourceKind == nil), so its kind cannot be determined. It wraps the sentinel errDatabaseNotFound, making it detectable via errors.Is.
Source
Thrown at cli/commands/migrate.go:283
func validateSourceInfo(ec *cli.ExecutionContext) error {
var op errors.Op = "commands.validateSourceInfo"
// find out the database kind by making a API call to server
// and update ec to include the database name and kind
sourceKind, err := metadatautil.GetSourceKind(
ec.APIClient.V1Metadata.ExportMetadata,
ec.Source.Name,
)
if err != nil {
return errors.E(
op,
fmt.Errorf("determining database kind of '%s': %w", ec.Source.Name, err),
)
}
if sourceKind == nil {
return errors.E(
op,
fmt.Errorf(
"%w: error determining database kind for '%s', check if database exists on hasura",
errDatabaseNotFound,
ec.Source.Name,
),
)
}
ec.Source.Kind = *sourceKind
return nil
}
func databaseChooser(ec *cli.ExecutionContext) error {
var op errors.Op = "commands.databaseChooser"
// prompt UI for choosing database if source name is not set
if ec.Source.Name == "" {
databaseName, err := metadatautil.DatabaseChooserUI(ec.APIClient.V1Metadata.ExportMetadata)
if err != nil {View on GitHub (pinned to 724551b9ae)
Solutions
- Run `hasura metadata export` and check sources[].name to confirm the exact source name
- Re-add the source (`hasura database add` or metadata apply) if it should exist
- Use the correct --database-name matching metadata exactly (case-sensitive)
- Point --endpoint at the environment that actually has this database
Defensive patterns
Strategy: validation
Validate before calling
hasura metadata export -o m.json jq -e --arg n "$DB" '.metadata.sources[] | select(.name==$n)' m.json >/dev/null || echo "source missing"
Try / catch
if errors.Is(err, migrate.ErrDatabaseNotFound) { /* re-add source or fix name */ } Prevention
- Always list sources via metadata export before --database-name runs
- Keep local migrations directories in sync with server-tracked sources
When it happens
Trigger: Running migrate commands with --database-name <name> where <name> is not a source in the server's metadata; or the migrations/<name> directory exists locally but the source was removed server-side.
Common situations: Renaming/removing a database in the console but keeping stale local migrations; typo in --database-name; pointing the CLI at a different environment/project than the one where the source was added.
Related errors
- error determining database kind for '%s', check if database
- error fetching config from server: %w
- error fetching server config: %v
- cannot get absolute path: %w
- error while creating http client with TLS configuration %w
AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28).
Data as JSON: /api/errors/27439b5dcf6cff78.
Report an issue: GitHub.