{"record":{"id":"3122474507f1337f","repo":"dgraph-io/dgraph","slug":"normalize-directive-is-not-supported-in-the-rdf-ou","errorCode":null,"errorMessage":"normalize directive is not supported in the rdf output format","messagePattern":"normalize directive is not supported in the rdf output format","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"query/outputrdf.go","lineNumber":223,"sourceCode":"\t\treturn buf\n\t}\n\tbuf := make([]byte, 0, overhead+len(val))\n\tbuf = append(buf, '<')\n\tbuf = append(buf, val...)\n\tbuf = append(buf, '>')\n\treturn buf\n}\n\nfunc validateSubGraphForRDF(sg *SubGraph) error {\n\tif sg.IsGroupBy() {\n\t\treturn errors.New(\"groupby is not supported in rdf output format\")\n\t}\n\tuidCount := sg.Attr == \"uid\" && sg.Params.DoCount && sg.IsInternal()\n\tif uidCount {\n\t\treturn errors.New(\"uid count is not supported in the rdf output format\")\n\t}\n\tif sg.Params.Normalize {\n\t\treturn errors.New(\"normalize directive is not supported in the rdf output format\")\n\t}\n\tif sg.Params.IgnoreReflex {\n\t\treturn errors.New(\"ignorereflex directive is not supported in the rdf output format\")\n\t}\n\tif sg.SrcFunc != nil && sg.SrcFunc.Name == \"checkpwd\" {\n\t\treturn errors.New(\"chkpwd function is not supported in the rdf output format\")\n\t}\n\tif sg.Params.Facet != nil && !sg.Params.ExpandAll {\n\t\treturn errors.New(\"facets are not supported in the rdf output format\")\n\t}\n\treturn nil\n}\n\nfunc quotedNumber(val []byte) []byte {\n\tconst overhead = 2 // opening and closing quotes\n\tif len(val) > math.MaxInt-overhead {\n\t\t// Extremely unlikely, but handle overflow case\n\t\ttmpVal := make([]byte, 0)","sourceCodeStart":205,"sourceCodeEnd":241,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/query/outputrdf.go#L205-L241","documentation":"The normalize directive flattens nested results into a single array, which only exists in JSON output. validateSubGraphForRDF rejects any sub-graph with sg.Params.Normalize set when serializing to RDF.","triggerScenarios":"Adding `@normalize` to a query (e.g. `query q($x: string) { me(func: eq(name, $x)) @normalize { name friend { name } } }`) while requesting RDF output.","commonSituations":"Templates that append @normalize for JSON shape control but keep a fixed RDF output header.","solutions":["Remove the @normalize directive","Switch to JSON output format","Do the flattening/reshaping client-side after receiving RDF"],"exampleFix":"// before\n{ me(func: eq(name, \"Alice\")) @normalize { friend { name } } }\n// after\n{ me(func: eq(name, \"Alice\")) { friend { name } } }","handlingStrategy":"validation","validationCode":"// Go: strip or reject @normalize when RDF output requested\nif strings.Contains(query, \"@normalize\") {\n    query = strings.ReplaceAll(query, \" @normalize\", \"\")\n}","typeGuard":"func usesNormalize(dql string) bool {\n    return strings.Contains(dql, \"@normalize\")\n}","tryCatchPattern":"res, err := txn.QueryRDF(ctx, dql)\nif err != nil && strings.Contains(err.Error(), \"normalize directive is not supported\") {\n    return txn.Query(ctx, strings.ReplaceAll(dql, \"@normalize\", \"\"))\n}","preventionTips":["Only add @normalize to JSON-output queries","Keep a single query-builder that knows the target output format","Flatten results client-side for RDF exports"],"tags":["dgraph","rdf","normalize","query-validation"],"backgroundTag":"feature-not-supported-in-rdf-output","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}