{"record":{"id":"349e56bce6bf1171","repo":"dgraph-io/dgraph","slug":"expecting-at-least-one-item-in-representations-a","errorCode":null,"errorMessage":"expecting at least one item in `representations` argument","messagePattern":"expecting at least one item in `representations` argument","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graphql/schema/wrappers.go","lineNumber":1716,"sourceCode":"func (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)\n\tif keyDir == nil {\n\t\treturn nil, fmt.Errorf(\"type %s doesn't have a key Directive\", typename)\n\t}","sourceCodeStart":1698,"sourceCodeEnd":1734,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/graphql/schema/wrappers.go#L1698-L1734","documentation":"Error returned when resolving a federated (_entities-like) query in graphql/schema/wrappers.go when the `representations` argument contains no items. The federation contract requires at least one representation object. Fix by passing a non-empty representations list.","triggerScenarios":"A federation _entities query sent with `representations: []` — usually when the gateway computed no matching entities for a federated field.","commonSituations":"Gateway routing an entities request where no federated type matched; misconfigured federation key causing zero representations to be collected.","solutions":["Ensure the query actually requests a field that produces at least one representation","Check federation key/config so the gateway emits representations for the entity","If legitimately empty, guard the caller to skip _entities resolution"],"exampleFix":"// before\nrepresentations: []\n// after\nrepresentations: [{__typename: \"Product\", id: \"1\"}]","handlingStrategy":"type-guard","validationCode":"reps, _ := args[\"representations\"].([]interface{})\nif len(reps) == 0 { skipEntities() }","typeGuard":"func hasRepresentations(v interface{}) bool {\n\treps, ok := v.([]interface{})\n\treturn ok && len(reps) > 0\n}","tryCatchPattern":"entity, err := q.RepresentationsArg()\nif err != nil && strings.Contains(err.Error(), \"at least one item\") {\n\treturn nil, nil // nothing to resolve; skip entities\n}","preventionTips":["Skip _entities resolution when the gateway produces zero representations","Check federation keys so gateways always emit representations when needed","Monitor gateway logs for empty-representation entity batches"],"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"}