{"record":{"id":"f7b4d17cc533d0b9","repo":"gastownhall/beads","slug":"database-s-has-no-child-data-sources","errorCode":null,"errorMessage":"database %s has no child data sources","messagePattern":"database (.+?) has no child data sources","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/notion/client.go","lineNumber":227,"sourceCode":"\t}\n\tidentifier := ExtractNotionIdentifier(ref)\n\tif identifier == \"\" {\n\t\treturn nil, fmt.Errorf(\"could not extract a Notion ID from %q\", ref)\n\t}\n\tif ds, err := client.RetrieveDataSource(ctx, identifier); err == nil {\n\t\treturn &ResolvedDataSource{\n\t\t\tInputID:      identifier,\n\t\t\tDataSourceID: ds.ID,\n\t\t\tDataSource:   ds,\n\t\t\tViewURL:      strings.TrimSpace(ref),\n\t\t}, nil\n\t} else {\n\t\tdb, dbErr := client.RetrieveDatabase(ctx, identifier)\n\t\tif dbErr != nil {\n\t\t\treturn nil, fmt.Errorf(\"resolve %q as data source: %w; as database: %v\", ref, err, dbErr)\n\t\t}\n\t\tif len(db.DataSources) == 0 || strings.TrimSpace(db.DataSources[0].ID) == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"database %s has no child data sources\", db.ID)\n\t\t}\n\t\tresolvedID := strings.TrimSpace(db.DataSources[0].ID)\n\t\tresolvedDS, err := client.RetrieveDataSource(ctx, resolvedID)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"retrieve child data source %s: %w\", resolvedID, err)\n\t\t}\n\t\treturn &ResolvedDataSource{\n\t\t\tInputID:      identifier,\n\t\t\tDataSourceID: resolvedID,\n\t\t\tDataSource:   resolvedDS,\n\t\t\tDatabase:     db,\n\t\t\tViewURL:      strings.TrimSpace(ref),\n\t\t}, nil\n\t}\n}\n\nfunc (c *Client) doRequest(ctx context.Context, method, path string, requestBody interface{}) ([]byte, error) {\n\tif c == nil {","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/notion/client.go#L209-L245","documentation":"When the reference resolves as a database, ResolveDataSourceReference expects db.DataSources to contain at least one entry with a non-empty ID so it can fetch the child data source. A database with an empty/missing data_sources list triggers this error.","triggerScenarios":"Calling ResolveDataSourceReference with a legacy database ID whose RetrieveDatabase response contains no data_sources array (pre data-source-model API version), or a database object returned with data_sources omitted by the pinned Notion-Version.","commonSituations":"Pinning an old Notion-Version header that predates the data_sources field; referencing an old-style database from before the 2025 API migration; a mock server or cached response lacking the field.","solutions":["Raise the Notion-Version header to one that populates data_sources on database responses (2025+ versions).","Upgrade the notion client library so Database parsing includes data_sources.","Reference the data source URL directly instead of going through the database fallback.","Confirm the referenced object is a database and not a plain page whose stub response lacks data_sources."],"exampleFix":"// before\nreq.Header.Set(\"Notion-Version\", \"2022-06-28\")\n// after\nreq.Header.Set(\"Notion-Version\", \"2025-09-03\") // data_sources populated on databases","handlingStrategy":"validation","validationCode":"db, err := client.RetrieveDatabase(ctx, id)\nif err == nil && (db == nil || len(db.DataSources) == 0) {\n    return fmt.Errorf(\"database %s exposes no data sources; update Notion-Version\", id)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use a Notion-Version that populates data_sources (2025+)","Keep the client library current","Prefer referencing the data source URL directly","Beware cached/mocked database responses lacking data_sources"],"tags":["notion","api-version","schema","resource-not-found"],"backgroundTag":"notion-api-version-mismatch","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}