{"record":{"id":"0061692bdc125e43","repo":"bytebase/bytebase","slug":"changelog-q-not-found","errorCode":null,"errorMessage":"changelog %q not found","messagePattern":"changelog %q not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/api/v1/database_service.go","lineNumber":1041,"sourceCode":"\t\tprojectID, instanceID, databaseID, changelogID, err := common.GetDatabaseChangelogResourceName(request.Name)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tinstance, err := s.getInstanceForDatabaseResource(ctx, projectID, instanceID)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tchangelog, err := s.store.GetChangelog(ctx, &store.FindChangelogMessage{\n\t\t\tInstanceID:   instanceID,\n\t\t\tDatabaseName: &databaseID,\n\t\t\tResourceID:   &changelogID,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif changelog == nil {\n\t\t\treturn nil, errors.Errorf(\"changelog %q not found\", changelogID)\n\t\t}\n\n\t\t// Use SyncHistory to get historical metadata\n\t\tif changelog.SyncHistory != nil {\n\t\t\tsyncHistory, err := s.store.GetSyncHistory(ctx, *changelog.SyncHistory)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tif syncHistory == nil {\n\t\t\t\treturn nil, errors.Errorf(\"sync history %s not found\", *changelog.SyncHistory)\n\t\t\t}\n\n\t\t\t// Get instance to determine engine and case sensitivity\n\t\t\treturn model.NewDatabaseMetadata(\n\t\t\t\tsyncHistory.Metadata,\n\t\t\t\t[]byte(syncHistory.Schema),\n\t\t\t\t&storepb.DatabaseConfig{},\n\t\t\t\tinstance.Metadata.GetEngine(),","sourceCodeStart":1023,"sourceCodeEnd":1059,"githubUrl":"https://github.com/bytebase/bytebase/blob/1870550677fe08f0d2a78c07acd27541464eb945/backend/api/v1/database_service.go#L1023-L1059","documentation":"Raised by getSourceDBMetadata when the requested resource name refers to a changelog (the name contains the changelogs/ prefix) but the store lookup for that changelog returns no row. getSourceDBMetadata backs DiffSchema for both the source side and (via resolveDiffSchemaTargetSDL) the changelog target side, so this error can surface for either. It signals the changelog ID does not exist for that instance/database.","triggerScenarios":"DiffSchema with request.Name (or target.Changelog) like projects/p/instances/i/databases/d/changelogs/<id> where GetChangelog finds nothing — deleted changelog, wrong ID, or changelog belongs to a different database.","commonSituations":"Changelog pruned by retention/cleanup policies; bookmarked diff URL pointing at a purged changelog; ID copied from a different database; cross-project changelog reference blocked earlier by validateDiffSchemaTargetProject.","solutions":["List current changelogs for the database and use an existing changelog ID.","Verify the changelog belongs to the exact instance/database in the resource name.","If the changelog was garbage-collected, pick a newer changelog or diff against raw schema text instead."],"exampleFix":"// before\nname := \"projects/p/instances/i/databases/d/changelogs/42\" // purged\n// after\nchangelogs := listChangelogs(db)\nname := changelogs[len(changelogs)-1].Name // use a live changelog","handlingStrategy":"validation","validationCode":"// Check the changelog exists before diffing\nconst cl = await api.listChangelogs({ parent: dbName, filter: `id = \"${changelogID}\"` })\nif (cl.changelogs.length === 0) throw new Error(`changelog ${changelogID} not found; pick a live one`)","typeGuard":null,"tryCatchPattern":"try {\n  diffSchema(req)\n} catch (e) {\n  if (/changelog .* not found/.test(e.Message)) {\n    const latest = await getLatestChangelog(dbName)\n    req.target = new DiffSchemaRequest.Changelog(latest.name)\n    return diffSchema(req)\n  }\n  throw e\n}","preventionTips":["Resolve changelog names via the changelist API at diff time instead of storing IDs.","Purge UI bookmarks/saved diffs whose changelogs fall outside retention.","Match changelog IDs against the exact instance/database path."],"tags":["changelog","resource-not-found","schema-diff","connect"],"backgroundTag":"record-not-found","analyzedSha":"1870550677fe08f0d2a78c07acd27541464eb945","analyzedAt":"2026-09-06T21:16:13.665Z","contentChangedAt":"2026-09-06T21:16:13.665Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}