{"record":{"id":"246e7536261ae063","repo":"hasura/graphql-engine","slug":"0-connected-sources-found-on-hasura","errorCode":null,"errorMessage":"0 connected sources found on hasura","messagePattern":"0 connected sources found on hasura","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/internal/metadatautil/sources.go","lineNumber":132,"sourceCode":"\n\t\t\tkind, _ := jsonparser.GetString(value, \"kind\")\n\t\t\tif len(name) > 0 && len(kind) > 0 {\n\t\t\t\tsources = append(sources, Source{\n\t\t\t\t\tName: name,\n\t\t\t\t\tKind: hasura.SourceKind(kind),\n\t\t\t\t})\n\t\t\t}\n\t\t},\n\t\t\"sources\",\n\t)\n\tif err != nil {\n\t\treturn nil, internalerrors.E(op, fmt.Errorf(\"jsonparser: %w\", err))\n\t}\n\n\treturn sources, nil\n}\n\nvar ErrNoConnectedSources = errors.New(\"0 connected sources found on hasura\")\n\n// GetSourcesAndKindStrict is like GetSourcesAndKind but will return an error when  no sources are found.\nfunc GetSourcesAndKindStrict(exportMetadata func() (io.Reader, error)) ([]Source, error) {\n\tvar op internalerrors.Op = \"metadatautil.GetSourcesAndKindStrict\"\n\n\tsources, err := GetSourcesAndKind(exportMetadata)\n\tif err != nil {\n\t\treturn nil, internalerrors.E(op, err)\n\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) {","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/internal/metadatautil/sources.go#L114-L150","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nsources, err := metadatautil.GetSourcesAndKindStrict(exportMetadata)\nif err != nil { return err }\n\n// after\nsources, err := metadatautil.GetSourcesAndKindStrict(exportMetadata)\nif errors.Is(err, metadatautil.ErrNoConnectedSources) {\n    return fmt.Errorf(\"no databases connected; run 'hasura db add' first\")\n}","handlingStrategy":"try-catch","validationCode":"sources, err := metadatautil.GetSourcesAndKind(exportMetadata)\nif err == nil && len(sources) > 0 {\n    // safe to call strict variant\n}","typeGuard":null,"tryCatchPattern":"sources, err := metadatautil.GetSourcesAndKindStrict(exportMetadata)\nif errors.Is(err, metadatautil.ErrNoConnectedSources) {\n    // prompt user to add a database\n}","preventionTips":["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"],"tags":["go","hasura-cli","sentinel-error","no-sources"],"backgroundTag":"empty-resource-not-found","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}