{"record":{"id":"312fe113b4c864b3","repo":"dgraph-io/dgraph","slug":"error-querying-cors","errorCode":null,"errorMessage":"error querying cors","messagePattern":"error querying cors","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upgrade/change_v21.03.0.go","lineNumber":210,"sourceCode":"\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc upgradeCORS() error {\n\tdg, cb := x.GetDgraphClient(Upgrade.Conf, hasAclCreds())\n\tdefer cb()\n\n\tjwt, err := getAccessJwt()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"while getting jwt auth token\")\n\t}\n\n\t// Get CORS.\n\tcorsData := make(map[string][]cors)\n\tif err := getQueryResult(dg, queryCORS_v21_03_0, &corsData); err != nil {\n\t\treturn errors.Wrap(err, \"error querying cors\")\n\t}\n\n\tvar corsList []string\n\tvar maxUid uint64\n\tfor _, cors := range corsData[\"cors\"] {\n\t\tuid, err := strconv.ParseUint(cors.UID, 0, 64)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif uid > maxUid {\n\t\t\tmaxUid = uid\n\t\t\tif len(cors.Cors) == 1 && cors.Cors[0] == \"*\" {\n\t\t\t\t// No need to update the GraphQL schema if all origins are allowed.\n\t\t\t\tcorsList = corsList[:0]\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tcorsList = cors.Cors\n\t\t}","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/upgrade/change_v21.03.0.go#L192-L228","documentation":"upgradeCORS runs queryCORS_v21_03_0 through getQueryResult to read existing cors entries. Failure is wrapped as 'error querying cors'. The DQL query fetching dgraph.cors data failed or the response could not be unmarshalled into the expected shape.","triggerScenarios":"getQueryResult errors while executing the CORS DQL query — unreachable Alpha, query rejected, or missing dgraph.cors predicate causing unexpected response.","commonSituations":"Clusters whose GraphQL layer was never initialized; expired JWT mid-upgrade; network/HTTP errors against the query endpoint.","solutions":["Verify the dgraph.cors predicate and GraphQL data exist in the cluster.","Check Alpha logs for the query error and address it.","Re-authenticate if the access token expired, then re-run.","Test the query manually with curl/Ratel before running the upgrade."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"curl -s http://localhost:8080/query -XPOST -d '{ q(func: has(dgraph.cors)) { uid dgraph.cors } }'","typeGuard":null,"tryCatchPattern":"if err := getQueryResult(dg, queryCORS_v21_03_0, &corsData); err != nil {\n\t// retry after re-auth / connectivity check\n\treturn errors.Wrap(err, \"error querying cors\")\n}","preventionTips":["Verify GraphQL layer data exists before migration","Re-authenticate on long-running upgrades","Check Alpha health endpoint before starting"],"tags":["dgraph","upgrade","dql","cors","query"],"backgroundTag":"dql-query-failed","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}