dgraph-io/dgraph · error

Geo id is not supported in rdf output

Error message

Geo id is not supported in rdf output

What it means

Dgraph's RDF output serializer can render most scalar values as triples, but geolocation values (types.GeoID) have no valid RDF literal representation in this path. getObjectVal returns this error rather than emitting a malformed triple when a geo value is encountered during rdfForSubgraph/rdfForValueList.

Source

Thrown at query/outputrdf.go:189

		}
		b.writeRDF(subject, []byte(attr), outputval)
	}
}

func getObjectVal(v types.Val) ([]byte, error) {
	outputval, err := valToBytes(v)
	if err != nil {
		return nil, err
	}
	switch v.Tid {
	case types.UidID:
		return buildTriple(outputval), nil
	case types.IntID:
		return quotedNumber(outputval), nil
	case types.FloatID:
		return quotedNumber(outputval), nil
	case types.GeoID:
		return nil, errors.New("Geo id is not supported in rdf output")
	default:
		return outputval, nil
	}
}

func buildTriple(val []byte) []byte {
	// Check for potential overflow in capacity calculation
	const overhead = 2 // '<' and '>'
	if len(val) > math.MaxInt-overhead {
		// Extremely unlikely, but handle overflow case
		// Fall back to append without pre-allocation
		buf := make([]byte, 0)
		buf = append(buf, '<')
		buf = append(buf, val...)
		buf = append(buf, '>')
		return buf
	}
	buf := make([]byte, 0, overhead+len(val))

View on GitHub (pinned to 759e242be6)

Solutions

  1. Exclude geo predicates from the RDF export/read (filter predicates in the query or export configuration)
  2. Use JSON output instead of RDF for data containing geo values (drop rdf format option)
  3. Convert geo values to string JSON before export if RDF is mandatory, then re-import as geo after
  4. Upgrade Dgraph if newer versions add geo support to the RDF path

Example fix

# before: export all including geo
dgraph graph export
# after: exclude geo predicates via query-only export
# export with query filtering out geo predicates, or read results as JSON
curl 'localhost:8080/query' -d '{ q(func: type(Place)) { uid name } }'
Defensive patterns

Strategy: validation

Validate before calling

const schema = await dgraph.schema();
const geoPreds = schema.filter(p => p.type === 'geo').map(p => p.predicate);
if (geoPreds.some(p => requestedPredicates.includes(p))) throw new Error('geo predicates unsupported in RDF output; use JSON');

Try / catch

try {
  return await exportRdf();
} catch (e) {
  if (String(e).includes('Geo id is not supported in rdf output')) {
    return await exportJson(); // fall back to JSON output
  }
  throw e;
}

Prevention

When it happens

Trigger: Exporting or reading (e.g. /mutate?commitNow with query, export to RDF, or rdf-format read) a node whose predicate holds a geo value (geo-type predicate), hitting the types.GeoID case in the RDF output path.

Common situations: Bulk export (/export) or all-nodes queries including geo predicates; move/export tooling over mixed-type graphs containing geo locations; admin export with RDF format.

Related errors


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