{"record":{"id":"bf65cc9b10c36cd4","repo":"dgraph-io/dgraph","slug":"error-parsing-representations-argument","errorCode":null,"errorMessage":"error parsing `representations` argument","messagePattern":"error parsing `representations` argument","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graphql/schema/wrappers.go","lineNumber":1713,"sourceCode":"\treturn (*field)(q).NullValue()\n}\n\nfunc (q *query) NullResponse() []byte {\n\treturn (*field)(q).NullResponse()\n}\n\nfunc (q *query) CompleteAlias(buf *bytes.Buffer) {\n\t(*field)(q).CompleteAlias(buf)\n}\n\nfunc (q *query) GetAuthMeta() *authorization.AuthMeta {\n\treturn (*field)(q).GetAuthMeta()\n}\n\nfunc (q *query) RepresentationsArg() (*EntityRepresentations, error) {\n\trepresentations, ok := q.ArgValue(\"representations\").([]interface{})\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"error parsing `representations` argument\")\n\t}\n\tif len(representations) == 0 {\n\t\treturn nil, fmt.Errorf(\"expecting at least one item in `representations` argument\")\n\t}\n\trepresentation, ok := representations[0].(map[string]interface{})\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"error parsing %dth item in the `_representations` argument\", 0)\n\t}\n\ttypename, ok := representation[Typename].(string)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unable to extract __typename from %dth item in the\"+\n\t\t\t\" `_representations` argument\", 0)\n\t}\n\ttyp := q.op.inSchema.schema.Types[typename]\n\tif typ == nil {\n\t\treturn nil, fmt.Errorf(\"type %s not found in the schema\", typename)\n\t}\n\tkeyDir := typ.Directives.ForName(apolloKeyDirective)","sourceCodeStart":1695,"sourceCodeEnd":1731,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/graphql/schema/wrappers.go#L1695-L1731","documentation":"RepresentationsArg parses the `representations` argument of the federated `_entities` query. This error is thrown when the argument value is not a []interface{} (list), meaning the client sent malformed or missing representations data.","triggerScenarios":"A federation _entities query whose `representations` argument is absent, null, or not a list (e.g. a single object instead of an array).","commonSituations":"A gateway/supergraph sending entities queries to a subgraph that isn't federation-enabled or whose schema disagrees with the gateway; hand-crafted _entities queries omitting representations.","solutions":["Send `representations` as a JSON array of objects in the _entities query","Verify the subgraph schema defines the federated `_service`/`_entities` contract correctly","Rebuild/republish the supergraph so gateway and subgraph schemas agree"],"exampleFix":"// before\n{ _entities(representations: {__typename: \"Product\", id: \"1\"}) ... }\n// after\n{ _entities(representations: [{__typename: \"Product\", id: \"1\"}]) ... }","handlingStrategy":"type-guard","validationCode":"if reps, ok := args[\"representations\"].([]interface{}); !ok || len(reps) == 0 {\n\treturn fmt.Errorf(\"representations must be a non-empty list\")\n}","typeGuard":"func validRepresentations(v interface{}) bool {\n\treps, ok := v.([]interface{})\n\treturn ok && len(reps) > 0\n}","tryCatchPattern":"entity, err := q.RepresentationsArg()\nif err != nil {\n\tif strings.Contains(err.Error(), \"error parsing `representations`\") {\n\t\treturn nil, fmt.Errorf(\"bad _entities request: %w\", err)\n\t}\n\treturn nil, err\n}","preventionTips":["Only send _entities requests through a federation-aware gateway","Validate entity payloads client-side before issuing _entities queries","Keep gateway and subgraph federation schemas in sync"],"tags":["graphql","federation","arguments"],"backgroundTag":"federation-representations-invalid","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}