{"record":{"id":"6d6565598cd8d6c5","repo":"dgraph-io/dgraph","slug":"no-new-node-was-created","errorCode":null,"errorMessage":"no new node was created","messagePattern":"no new node was created","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graphql/resolve/mutation_rewriter.go","lineNumber":781,"sourceCode":"\n\t// Find any newly added/updated rootUIDs.\n\tuids, err := convertIDsWithErr(arw.MutatedRootUIDs(mutation, assigned, result))\n\terrs = schema.AppendGQLErrs(errs, err)\n\n\t// Find out if its an upsert with Add mutation.\n\t// In this case, it may happen that no new node is created, but there may still\n\t// be some updated nodes. We don't throw an error in this case.\n\tupsert := false\n\tupsertVal := mutation.ArgValue(schema.UpsertArgName)\n\tif upsertVal != nil {\n\t\tupsert = upsertVal.(bool)\n\t}\n\n\t// This error is only relevant in case this is not an Upsert with Add Mutation.\n\t// During upsert with Add mutation, it may happen that no new nodes are created and\n\t// everything is perfectly alright.\n\tif len(uids) == 0 && errs == nil && !upsert {\n\t\terrs = schema.AsGQLErrors(errors.Errorf(\"no new node was created\"))\n\t}\n\n\tcustomClaims, err := mutation.GetAuthMeta().ExtractCustomClaims(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tauthRw := &authRewriter{\n\t\tauthVariables: customClaims.AuthVariables,\n\t\tvarGen:        NewVariableGenerator(),\n\t\tselector:      queryAuthSelector,\n\t\tparentVarName: mutation.MutatedType().Name() + \"Root\",\n\t}\n\tauthRw.hasAuthRules = hasAuthRules(mutation.QueryField(), authRw)\n\n\tif errs != nil {\n\t\treturn nil, errs\n\t}","sourceCodeStart":763,"sourceCodeEnd":799,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/graphql/resolve/mutation_rewriter.go#L763-L799","documentation":"FromMutationResult builds the mutation response from the UIDs returned by the write. If no UIDs were created (len(uids)==0), there were no errors, and the mutation is not an upsert-with-Add, something went wrong silently, so this error is raised. For upserts, zero new nodes is legitimate (all data already existed), which is why upsert is exempted.","triggerScenarios":"An Add mutation reported no errors but returned zero UIDs and was not part of an upsert block — e.g. the underlying Dgraph write created no nodes.","commonSituations":"Upsert flag incorrectly not set for upsert-with-add flows; add mutation silently matched existing nodes without creating; backend returned empty UID map due to a bug or version mismatch.","solutions":["Verify the Add mutation input actually contains new nodes to create","If using upsert-with-Add, ensure the upsert flag is passed to FromMutationResult","Inspect the underlying DQL upsert block to see why no UIDs were returned","Check for library/version issues where the UID map is dropped before being returned"],"exampleFix":"// before\nFromMutationResult(mutation, uids, preds, nil) // upsert omitted\n// after\nFromMutationResult(mutation, uids, preds, nil, WithUpsert(true))","handlingStrategy":"try-catch","validationCode":"if (!upsert && (!uids || Object.keys(uids).length === 0)) {\n  throw new Error('no new node was created');\n}","typeGuard":"function hasCreatedNodes(uids) {\n  return uids != null && typeof uids === 'object' && Object.keys(uids).length > 0;\n}","tryCatchPattern":"try {\n  result = FromMutationResult(mutation, uids, preds, errs);\n} catch (err) {\n  if (err.message.includes('no new node was created')) {\n    // verify upsert flag or that input actually creates nodes\n  }\n}","preventionTips":["Pass WithUpsert(true) for upsert-with-add flows","Assert Add inputs contain at least one node","Log UID maps before constructing results","Add tests covering add-vs-upsert result handling"],"tags":["graphql","mutation","upsert"],"backgroundTag":"no-nodes-created","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}