dgraph-io/dgraph · error

error querying cors

Error message

error querying cors

What it means

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.

Source

Thrown at upgrade/change_v21.03.0.go:210

		}
	}

	return nil
}

func upgradeCORS() error {
	dg, cb := x.GetDgraphClient(Upgrade.Conf, hasAclCreds())
	defer cb()

	jwt, err := getAccessJwt()
	if err != nil {
		return errors.Wrap(err, "while getting jwt auth token")
	}

	// Get CORS.
	corsData := make(map[string][]cors)
	if err := getQueryResult(dg, queryCORS_v21_03_0, &corsData); err != nil {
		return errors.Wrap(err, "error querying cors")
	}

	var corsList []string
	var maxUid uint64
	for _, cors := range corsData["cors"] {
		uid, err := strconv.ParseUint(cors.UID, 0, 64)
		if err != nil {
			return err
		}
		if uid > maxUid {
			maxUid = uid
			if len(cors.Cors) == 1 && cors.Cors[0] == "*" {
				// No need to update the GraphQL schema if all origins are allowed.
				corsList = corsList[:0]
				continue
			}
			corsList = cors.Cors
		}

View on GitHub (pinned to 759e242be6)

Solutions

  1. Verify the dgraph.cors predicate and GraphQL data exist in the cluster.
  2. Check Alpha logs for the query error and address it.
  3. Re-authenticate if the access token expired, then re-run.
  4. Test the query manually with curl/Ratel before running the upgrade.
Defensive patterns

Strategy: retry

Validate before calling

curl -s http://localhost:8080/query -XPOST -d '{ q(func: has(dgraph.cors)) { uid dgraph.cors } }'

Try / catch

if err := getQueryResult(dg, queryCORS_v21_03_0, &corsData); err != nil {
	// retry after re-auth / connectivity check
	return errors.Wrap(err, "error querying cors")
}

Prevention

When it happens

Trigger: getQueryResult errors while executing the CORS DQL query — unreachable Alpha, query rejected, or missing dgraph.cors predicate causing unexpected response.

Common situations: Clusters whose GraphQL layer was never initialized; expired JWT mid-upgrade; network/HTTP errors against the query endpoint.

Related errors


AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01). Data as JSON: /api/errors/312fe113b4c864b3. Report an issue: GitHub.