{"record":{"id":"ce8b01c89d00f05f","repo":"dgraph-io/dgraph","slug":"got-unsupported-type-for-list-s","errorCode":null,"errorMessage":"got unsupported type for list: %s","messagePattern":"got unsupported type for list: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"chunker/json_parser.go","lineNumber":645,"sourceCode":"\t\t\t\t\tok, err := handleGeoType(item.(map[string]interface{}), &nq)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn mr, err\n\t\t\t\t\t}\n\t\t\t\t\tif ok {\n\t\t\t\t\t\tbuf.Push(&nq)\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\n\t\t\t\t\tcr, err := buf.mapToNquads(iv, op, pred)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn mr, err\n\t\t\t\t\t}\n\t\t\t\t\tnq.ObjectId = cr.uid\n\t\t\t\t\tnq.Facets = cr.fcts\n\t\t\t\t\tbuf.Push(&nq)\n\t\t\t\tdefault:\n\t\t\t\t\treturn mr,\n\t\t\t\t\t\tfmt.Errorf(\"got unsupported type for list: %s\", pred)\n\t\t\t\t}\n\t\t\t}\n\t\tdefault:\n\t\t\treturn mr, fmt.Errorf(\"unexpected type for val for attr: %s while converting to nquad\", pred)\n\t\t}\n\t}\n\n\tfts, err := parseScalarFacets(mr.rawFacets, parentPred+x.FacetDelimiter)\n\tmr.fcts = fts\n\n\treturn mr, err\n}\n\nconst (\n\t// SetNquads is the constant used to indicate that the parsed NQuads are meant to be added.\n\tSetNquads = iota\n\t// DeleteNquads is the constant used to indicate that the parsed NQuads are meant to be\n\t// deleted.","sourceCodeStart":627,"sourceCodeEnd":663,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/chunker/json_parser.go#L627-L663","documentation":"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.","triggerScenarios":"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`.","commonSituations":"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.","solutions":["Flatten nested arrays so each element is a scalar or a map (node object).","Remove null entries from lists, or replace them with a sentinel value.","Ensure list elements are only strings, numbers, booleans, or map[string]interface{} objects."],"exampleFix":"// before\n{\"tags\": [null, [\"x\"]]}\n// after\n{\"tags\": [\"x\"]}","handlingStrategy":"type-guard","validationCode":"func listElementsSupported(v []interface{}) bool {\n\tfor _, e := range v {\n\t\tswitch e.(type) {\n\t\tcase nil, []interface{}:\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}","typeGuard":"func validListElement(e interface{}) bool {\n\tswitch e.(type) {\n\tcase string, bool, float64, int64, map[string]interface{}:\n\t\treturn true\n\t}\n\treturn false\n}","tryCatchPattern":"if err := buf.ParseJSON(b, op); err != nil && strings.Contains(err.Error(), \"got unsupported type for list\") {\n\t// flatten/repair the offending predicate's array and retry\n}","preventionTips":["Flatten nested arrays before import","Strip nulls from arrays","Keep list elements limited to scalars or node objects"],"tags":["json-parser","list","unsupported-type","dgraph"],"backgroundTag":"unsupported-list-element-type","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}