dgraph-io/dgraph · error

got unsupported type for list: %s

Error message

got unsupported type for list: %s

What it means

In mapToNquads (chunker/json_parser.go:645), when an attribute value is a JSON array, each element is converted according to its Go type (string, bool, numeric, map, etc.). An element whose type is not supported for lists falls to the default branch, producing this error naming the predicate. It means the array contained an item the parser cannot turn into an NQuad edge/value.

Source

Thrown at chunker/json_parser.go:645

					ok, err := handleGeoType(item.(map[string]interface{}), &nq)
					if err != nil {
						return mr, err
					}
					if ok {
						buf.Push(&nq)
						continue
					}

					cr, err := buf.mapToNquads(iv, op, pred)
					if err != nil {
						return mr, err
					}
					nq.ObjectId = cr.uid
					nq.Facets = cr.fcts
					buf.Push(&nq)
				default:
					return mr,
						fmt.Errorf("got unsupported type for list: %s", pred)
				}
			}
		default:
			return mr, fmt.Errorf("unexpected type for val for attr: %s while converting to nquad", pred)
		}
	}

	fts, err := parseScalarFacets(mr.rawFacets, parentPred+x.FacetDelimiter)
	mr.fcts = fts

	return mr, err
}

const (
	// SetNquads is the constant used to indicate that the parsed NQuads are meant to be added.
	SetNquads = iota
	// DeleteNquads is the constant used to indicate that the parsed NQuads are meant to be
	// deleted.

View on GitHub (pinned to 759e242be6)

Solutions

  1. Flatten nested arrays so each element is a scalar or a map (node object).
  2. Remove null entries from lists, or replace them with a sentinel value.
  3. Ensure list elements are only strings, numbers, booleans, or map[string]interface{} objects.

Example fix

// before
{"tags": [null, ["x"]]}
// after
{"tags": ["x"]}
Defensive patterns

Strategy: type-guard

Validate before calling

func listElementsSupported(v []interface{}) bool {
	for _, e := range v {
		switch e.(type) {
		case nil, []interface{}:
			return false
		}
	}
	return true
}

Type guard

func validListElement(e interface{}) bool {
	switch e.(type) {
	case string, bool, float64, int64, map[string]interface{}:
		return true
	}
	return false
}

Try / catch

if err := buf.ParseJSON(b, op); err != nil && strings.Contains(err.Error(), "got unsupported type for list") {
	// flatten/repair the offending predicate's array and retry
}

Prevention

When it happens

Trigger: Calling ParseJSON/FastParseJSON (or ParseMutationObject) with a JSON attribute whose value is an array containing an unsupported element type — typically nested arrays ([][]interface{}) or null elements — for predicate `pred`.

Common situations: JSON like {"friends": [[...]]} (array of arrays) or {"tags": [null, "a"]} produced by upstream tools; deep recursion is seen because mapToNquads calls itself for object elements.

Related errors


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