{"record":{"id":"052425b9cd86b50c","repo":"hasura/graphql-engine","slug":"no-connected-databases-found-in-the-server","errorCode":null,"errorMessage":"no connected databases found in the server","messagePattern":"no connected databases found in the server","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/internal/metadatautil/sources.go","lineNumber":159,"sourceCode":"\t}\n\n\tif len(sources) == 0 {\n\t\treturn nil, internalerrors.E(op, ErrNoConnectedSources)\n\t}\n\n\treturn sources, nil\n}\n\nfunc DatabaseChooserUI(exportMetadata func() (io.Reader, error)) (string, error) {\n\tvar op internalerrors.Op = \"metadatautil.DatabaseChooserUI\"\n\n\tsources, err := GetSources(exportMetadata)\n\tif err != nil {\n\t\treturn \"\", internalerrors.E(op, fmt.Errorf(\"unable to get available databases: %w\", err))\n\t}\n\n\tif len(sources) == 0 {\n\t\treturn \"\", internalerrors.E(op, errors.New(\"no connected databases found in the server\"))\n\t}\n\n\tdatabaseName, err := util.GetSelectPrompt(\"Select a database to use\", sources)\n\tif err != nil {\n\t\treturn \"\", internalerrors.E(op, fmt.Errorf(\"error in selecting a database to use: %w\", err))\n\t}\n\n\treturn databaseName, nil\n}\n\nconst ChooseAllDatabases = \"All (all available databases)\"\n\nfunc DatabaseChooserUIWithAll(exportMetadata func() (io.Reader, error)) (string, error) {\n\tvar op internalerrors.Op = \"metadatautil.DatabaseChooserUIWithAll\"\n\n\tsources, err := GetSources(exportMetadata)\n\tif err != nil {\n\t\treturn \"\", internalerrors.E(op, fmt.Errorf(\"unable to get available databases: %w\", err))","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/internal/metadatautil/sources.go#L141-L177","documentation":"DatabaseChooserUI returns this when the metadata parsed successfully but the sources list is empty — the Hasura instance has no connected databases to offer in the select prompt. It is a user-facing interactive-flow error, not a parse failure.","triggerScenarios":"Running any command that triggers the database selection prompt against a Hasura server with zero connected sources. The prompt cannot be shown because there is nothing to select.","commonSituations":"New/fresh Hasura instance before any database is added; wrong endpoint (querying an empty dev instance instead of the populated one); sources removed during cleanup.","solutions":["Connect a database to the Hasura instance (hasura db add / console)","Verify HASURA_GRAPHQL_ENDPOINT and admin secret target the intended instance","If expecting sources, export metadata and confirm the sources array is populated"],"exampleFix":"// before\ndb, err := metadatautil.DatabaseChooserUI(exportMetadata)\nif err != nil { return err }\n\n// after\ndb, err := metadatautil.DatabaseChooserUI(exportMetadata)\nif err != nil && strings.Contains(err.Error(), \"no connected databases\") {\n    return fmt.Errorf(\"connect a database first (hasura db add), then re-run\")\n}\nif err != nil { return err }","handlingStrategy":"validation","validationCode":"sources, err := metadatautil.GetSources(exportMetadata)\nif err == nil && len(sources) == 0 {\n    // skip chooser, tell user to connect a database\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"no connected databases\") {\n    // friendly guidance\n}","preventionTips":["Pre-check sources with GetSources","Ensure a database is connected before running interactive commands"],"tags":["go","hasura-cli","no-sources","interactive-prompt"],"backgroundTag":"empty-resource-not-found","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}