hasura/graphql-engine · error
0 connected sources found on hasura
Error message
0 connected sources found on hasura
What it means
ErrNoConnectedSources is a sentinel error declared in metadatautil and returned by GetSourcesAndKindStrict when the metadata parses fine but contains zero sources (no databases are connected to the Hasura instance). Unlike the jsonparser errors it is not a parse failure: the metadata simply lists no connected databases.
Source
Thrown at cli/internal/metadatautil/sources.go:132
kind, _ := jsonparser.GetString(value, "kind")
if len(name) > 0 && len(kind) > 0 {
sources = append(sources, Source{
Name: name,
Kind: hasura.SourceKind(kind),
})
}
},
"sources",
)
if err != nil {
return nil, internalerrors.E(op, fmt.Errorf("jsonparser: %w", err))
}
return sources, nil
}
var ErrNoConnectedSources = errors.New("0 connected sources found on hasura")
// GetSourcesAndKindStrict is like GetSourcesAndKind but will return an error when no sources are found.
func GetSourcesAndKindStrict(exportMetadata func() (io.Reader, error)) ([]Source, error) {
var op internalerrors.Op = "metadatautil.GetSourcesAndKindStrict"
sources, err := GetSourcesAndKind(exportMetadata)
if err != nil {
return nil, internalerrors.E(op, err)
}
if len(sources) == 0 {
return nil, internalerrors.E(op, ErrNoConnectedSources)
}
return sources, nil
}
func DatabaseChooserUI(exportMetadata func() (io.Reader, error)) (string, error) {View on GitHub (pinned to 724551b9ae)
Solutions
- Connect a database to the Hasura instance first, then retry
- Verify the endpoint/admin secret point at the intended project (you may be hitting an empty instance)
- Use errors.Is(err, metadatautil.ErrNoConnectedSources) to give a friendly prompt instead of a raw failure
Example fix
// before
sources, err := metadatautil.GetSourcesAndKindStrict(exportMetadata)
if err != nil { return err }
// after
sources, err := metadatautil.GetSourcesAndKindStrict(exportMetadata)
if errors.Is(err, metadatautil.ErrNoConnectedSources) {
return fmt.Errorf("no databases connected; run 'hasura db add' first")
} Defensive patterns
Strategy: try-catch
Validate before calling
sources, err := metadatautil.GetSourcesAndKind(exportMetadata)
if err == nil && len(sources) > 0 {
// safe to call strict variant
} Try / catch
sources, err := metadatautil.GetSourcesAndKindStrict(exportMetadata)
if errors.Is(err, metadatautil.ErrNoConnectedSources) {
// prompt user to add a database
} Prevention
- Check source count before requiring strict semantics
- Connect a database before running source-dependent commands
- Use errors.Is against the sentinel rather than string matching
When it happens
Trigger: Calling GetSourcesAndKindStrict(exportMetadata) on a fresh Hasura instance where no database has been connected yet, or after all sources were dropped. Any command requiring at least one source (e.g. metadata apply flows) will abort with this error.
Common situations: Fresh Hasura setup before running 'hasura db add' / connecting a database; CI environments pointing at a blank instance; mistakenly targeting the wrong project/endpoint so a different, empty server is queried.
Related errors
- no connected databases found in the server
- failed to get the matching platform for plugin %s: %w
- jsonparser: %w
- unable to get available databases: %w
- error in selecting a database to use: %w
AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28).
Data as JSON: /api/errors/246e7536261ae063.
Report an issue: GitHub.