{"record":{"id":"19e8125ac8c39ea5","repo":"bytebase/bytebase","slug":"table-s-not-found-in-schema","errorCode":null,"errorMessage":"table %s not found in schema","messagePattern":"table (.+?) not found in schema","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/plugin/parser/mysql/backup.go","lineNumber":689,"sourceCode":"\n\tschema := dbMetadata.GetSchemaMetadata(\"\")\n\tif schema == nil {\n\t\treturn nil, nil, errors.New(\"failed to get schema metadata\")\n\t}\n\n\tvar tableSchema *model.TableMetadata\n\tif !isCaseSensitive {\n\t\tfor _, tableName := range schema.ListTableNames() {\n\t\t\tif strings.EqualFold(tableName, table.Table) {\n\t\t\t\ttableSchema = schema.GetTable(tableName)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t} else {\n\t\ttableSchema = schema.GetTable(table.Table)\n\t}\n\tif tableSchema == nil {\n\t\treturn nil, nil, errors.Errorf(\"table %s not found in schema\", table.Table)\n\t}\n\n\tvar generatedColumns, normalColumns []string\n\tfor _, column := range tableSchema.GetProto().GetColumns() {\n\t\tif column.GetGeneration() != nil {\n\t\t\tgeneratedColumns = append(generatedColumns, column.GetName())\n\t\t} else {\n\t\t\tnormalColumns = append(normalColumns, column.GetName())\n\t\t}\n\t}\n\n\treturn generatedColumns, normalColumns, nil\n}\n","sourceCodeStart":671,"sourceCodeEnd":703,"githubUrl":"https://github.com/bytebase/bytebase/blob/1870550677fe08f0d2a78c07acd27541464eb945/backend/plugin/parser/mysql/backup.go#L671-L703","documentation":"classifyColumns in the MySQL backup generator resolves a table's schema metadata from the previously synced catalog metadata. It looks up the table by name (case-insensitively or exactly depending on case-sensitivity settings) in the default schema of the database metadata; if the lookup returns nil it cannot split columns into generated vs normal columns and throws this error. It indicates the queried table does not exist in Bytebase's cached schema metadata for that database.","triggerScenarios":"generateSQLForTable/doGenerate are called with a TableMetadata{name, database} whose table name is absent from the database's schema metadata — the database exists but the table name in the backup config does not match any table in the synced metadata (case-sensitive mode requires exact match).","commonSituations":"Table was dropped after backup task creation; stale/incomplete schema catalog because the instance metadata hasn't been synced since the table was created; case mismatch between config and actual table name on a case-sensitive setup; typo in table name; referencing a table from the wrong database.","solutions":["Verify the table name in the backup configuration matches an existing table (check case exactly on case-sensitive instances).","Re-sync the instance/database schema metadata in Bytebase so the catalog contains the table.","Confirm the backup task targets the correct database — the lookup only searches that database's default schema.","If the table was recently created, wait for/trigger a metadata sync before running the backup."],"exampleFix":"// before: metadata never synced, table missing from catalog\n// after: ensure sync before classifying\nif err := syncDatabaseMetadata(ctx, instanceID, table.Database); err != nil {\n\treturn nil, nil, err\n}\ntableSchema = schema.GetTable(table.Table)","handlingStrategy":"validation","validationCode":"schema := dbMetadata.GetSchemaMetadata(\"\")\nif schema == nil {\n\treturn errors.New(\"schema metadata unavailable; sync the database first\")\n}\nfound := false\nfor _, name := range schema.ListTableNames() {\n\tif strings.EqualFold(name, table.Table) { found = true; break }\n}\nif !found {\n\treturn fmt.Errorf(\"table %q not present in metadata; re-sync before backup\", table.Table)\n}","typeGuard":"func tableInSchema(schema *model.SchemaMetadata, name string) bool {\n\tif schema == nil { return false }\n\tfor _, t := range schema.ListTableNames() {\n\t\tif strings.EqualFold(t, name) { return true }\n\t}\n\treturn false\n}","tryCatchPattern":"if _, _, err := classifyColumns(ctx, instanceID, table, meta); err != nil {\n\tif strings.Contains(err.Error(), \"not found in schema\") {\n\t\t// mark backup task as failed-needs-sync and trigger metadata sync\n\t\treturn reconcileMetadataAndRetry(ctx, instanceID, table.Database)\n\t}\n\treturn err\n}","preventionTips":["Always run a schema metadata sync after DDL changes and before scheduling backups.","Validate backup task table names against the catalog at task-creation time, not at execution time.","Be explicit about case sensitivity when generating table names in configs."],"tags":["mysql","metadata","backup","table-not-found"],"backgroundTag":"resource-not-found","analyzedSha":"1870550677fe08f0d2a78c07acd27541464eb945","analyzedAt":"2026-09-06T21:16:13.665Z","contentChangedAt":"2026-09-06T21:16:13.665Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}