{"record":{"id":"dc14b957a86d647d","repo":"dgraph-io/dgraph","slug":"while-upgrading-cors","errorCode":null,"errorMessage":"while upgrading cors","messagePattern":"while upgrading cors","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upgrade/change_v21.03.0.go","lineNumber":443,"sourceCode":"\t\treturn err\n\t}\n\tentry = &badger.Entry{}\n\tentry.Key = x.TypeKey(x.AttrInRootNamespace(\"dgraph.graphql.persisted_query\"))\n\tentry.Value = data\n\tentry.UserMeta = posting.BitSchemaPosting\n\tif err := update(entry); err != nil {\n\t\treturn errors.Wrap(err, \"while updating persisted query's type\")\n\t}\n\treturn nil\n}\n\n// OfflineUpgradeFrom2011To2103 upgrades a p directory restored from backup of 20.11 to the changes\n// in 21.03. It fixes the cors, schema and drops the deprecated types/predicates.\nfunc OfflineUpgradeFrom2011To2103(db *badger.DB) error {\n\tif err := fixPersistedQuery(db); err != nil {\n\t\treturn errors.Wrapf(err, \"while upgrading persisted query\")\n\t}\n\treturn errors.Wrapf(fixCors(db), \"while upgrading cors\")\n}\n","sourceCodeStart":425,"sourceCodeEnd":445,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/upgrade/change_v21.03.0.go#L425-L445","documentation":"OfflineUpgradeFrom2011To2103 wraps any fixCors failure with this message. It means the CORS/GraphQL-schema fix portion of the 20.11 -> 21.03 offline upgrade failed; the wrapped chain includes the updateGQLSchemaOffline or dropDepreciated error.","triggerScenarios":"Calling OfflineUpgradeFrom2011To2103 where fixCors returns an error: getCors read failure, updateGQLSchemaOffline write failure, or dropDepreciated failure on the restored badger DB.","commonSituations":"Migrating restored 20.11 backups to 21.03; corrupted or partially-restored p directories; badger I/O errors mid-migration.","solutions":["Log the full wrapped chain (%+v) to see whether getCors, updateGQLSchemaOffline, or dropDepreciated failed, and address that specific cause.","Re-restore the backup from the original file and rerun the upgrade.","Stop all dgraph processes so the p directory is exclusively available to the upgrade.","Verify disk space and badger directory integrity before retrying."],"exampleFix":"// before\nerr := upgrade.OfflineUpgradeFrom2011To2103(db)\nlog.Println(err) // \"while upgrading cors: ...\" without detail\n// after\nlog.Printf(\"%+v\", err) // full cause chain","handlingStrategy":"try-catch","validationCode":"// Verify cors/schema entries are readable before the upgrade\nif err := db.View(func(txn *badger.Txn) error {\n\t_, err := txn.Get([]byte(\"~graphql.schema\"))\n\treturn err\n}); err != nil {\n\tlog.Fatalf(\"schema entry unreadable: %v\", err)\n}","typeGuard":"func isCorsUpgradeErr(err error) bool {\n\treturn err != nil && strings.Contains(err.Error(), \"while upgrading cors\")\n}","tryCatchPattern":"if err := upgrade.OfflineUpgradeFrom2011To2103(db); err != nil {\n\tlog.Fatalf(\"cors upgrade failed: %+v\", err)\n}","preventionTips":["Re-restore backups cleanly before upgrading","Check disk space and permissions on the p directory","Stop dgraph so badger is exclusively available","Log the full error chain to identify getCors vs updateGQLSchemaOffline vs dropDepreciated"],"tags":["migration","offline-upgrade","cors","badger"],"backgroundTag":"offline-schema-upgrade-failed","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}