dgraph-io/dgraph · error
no new node was created
Error message
no new node was created
What it means
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.
Source
Thrown at graphql/resolve/mutation_rewriter.go:781
// Find any newly added/updated rootUIDs.
uids, err := convertIDsWithErr(arw.MutatedRootUIDs(mutation, assigned, result))
errs = schema.AppendGQLErrs(errs, err)
// Find out if its an upsert with Add mutation.
// In this case, it may happen that no new node is created, but there may still
// be some updated nodes. We don't throw an error in this case.
upsert := false
upsertVal := mutation.ArgValue(schema.UpsertArgName)
if upsertVal != nil {
upsert = upsertVal.(bool)
}
// This error is only relevant in case this is not an Upsert with Add Mutation.
// During upsert with Add mutation, it may happen that no new nodes are created and
// everything is perfectly alright.
if len(uids) == 0 && errs == nil && !upsert {
errs = schema.AsGQLErrors(errors.Errorf("no new node was created"))
}
customClaims, err := mutation.GetAuthMeta().ExtractCustomClaims(ctx)
if err != nil {
return nil, err
}
authRw := &authRewriter{
authVariables: customClaims.AuthVariables,
varGen: NewVariableGenerator(),
selector: queryAuthSelector,
parentVarName: mutation.MutatedType().Name() + "Root",
}
authRw.hasAuthRules = hasAuthRules(mutation.QueryField(), authRw)
if errs != nil {
return nil, errs
}View on GitHub (pinned to 759e242be6)
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
Example fix
// before FromMutationResult(mutation, uids, preds, nil) // upsert omitted // after FromMutationResult(mutation, uids, preds, nil, WithUpsert(true))
Defensive patterns
Strategy: try-catch
Validate before calling
if (!upsert && (!uids || Object.keys(uids).length === 0)) {
throw new Error('no new node was created');
} Type guard
function hasCreatedNodes(uids) {
return uids != null && typeof uids === 'object' && Object.keys(uids).length > 0;
} Try / catch
try {
result = FromMutationResult(mutation, uids, preds, errs);
} catch (err) {
if (err.message.includes('no new node was created')) {
// verify upsert flag or that input actually creates nodes
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- error while parsing [%v]
- can't convert input to map
- can't convert input.what to string
- can't convert input to map
- can't convert input to map
AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01).
Data as JSON: /api/errors/6d6565598cd8d6c5.
Report an issue: GitHub.