{"record":{"id":"db1a2a833d8d3388","repo":"bytebase/bytebase","slug":"failed-to-extract-resource-list","errorCode":null,"errorMessage":"failed to extract resource list","messagePattern":"failed to extract resource list","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/api/v1/sql_service.go","lineNumber":1242,"sourceCode":"\tstores *store.Store,\n\tinstance *store.InstanceMessage,\n\tdatabase *store.DatabaseMessage,\n\tresult *v1pb.QueryResult,\n\trequest *v1pb.ExportRequest,\n) error {\n\tresourceList, err := export.GetResources(\n\t\tctx,\n\t\tstores,\n\t\tinstance.Metadata.GetEngine(),\n\t\tdatabase.DatabaseName,\n\t\trequest.Statement,\n\t\tinstance,\n\t\tparsercontext.BuildGetDatabaseMetadataFunc(stores),\n\t\tparsercontext.BuildListDatabaseNamesFunc(stores),\n\t\tparsercontext.BuildGetLinkedDatabaseMetadataFunc(stores, instance.Metadata.GetEngine()),\n\t)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"failed to extract resource list\")\n\t}\n\tstatementPrefix, err := export.SQLStatementPrefix(instance.Metadata.GetEngine(), resourceList, result.ColumnNames)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn export.SQLToWriter(w, instance.Metadata.GetEngine(), statementPrefix, result)\n}\n\nfunc (s *SQLService) createQueryHistory(instance *store.InstanceMessage, database *store.DatabaseMessage, queryType store.QueryHistoryType, statement string, userEmail string, duration time.Duration, queryErr error) {\n\tqh := &store.QueryHistoryMessage{\n\t\tCreator:   userEmail,\n\t\tProject:   database.ProjectID,\n\t\tDatabase:  formatDatabaseResourceName(instance, database),\n\t\tStatement: statement,\n\t\tType:      queryType,\n\t\tPayload: &storepb.QueryHistoryPayload{\n\t\t\tError:    nil,\n\t\t\tDuration: durationpb.New(duration),","sourceCodeStart":1224,"sourceCodeEnd":1260,"githubUrl":"https://github.com/bytebase/bytebase/blob/1870550677fe08f0d2a78c07acd27541464eb945/backend/api/v1/sql_service.go#L1224-L1260","documentation":"exportSQLWithContext extracts the resource list (table/schema references) from the exported statement using the SQL parser and metadata lookup helpers before rendering INSERT statements; a failure is wrapped with this message. The statement's referenced resources could not be resolved against database metadata.","triggerScenarios":"The parser or metadata provider (BuildGetDatabaseMetadataFunc / BuildListDatabaseNamesFunc / BuildGetLinkedDatabaseMetadataFunc) fails — e.g. metadata store errors, unparseable statement, or missing linked database metadata.","commonSituations":"Exporting SQL for statements referencing objects missing from metadata cache, linked-database (foreign) metadata unavailable for the engine, or parser not supporting the dialect syntax in the statement.","solutions":["Read the wrapped inner error to see if it's a parse error or metadata lookup failure","Refresh database metadata (sync schema) so referenced tables can be resolved","Verify linked database metadata exists if the statement uses cross-database references","Retry; transient store errors during metadata lookup can also surface here"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// ensure metadata is synced\nawait databaseService.syncDatabaseSchema({ database: dbName })","typeGuard":null,"tryCatchPattern":"try { await client.export({...req, format: 'SQL'}) } catch (e) { if (e.message.includes('failed to extract resource list')) { /* re-sync metadata then retry */ } throw e }","preventionTips":["Sync database metadata before SQL-format exports","Avoid cross-database references lacking linked metadata","Retry on transient metadata store errors"],"tags":["export","sql","parser","metadata"],"backgroundTag":"database-query-failed","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"}