{"record":{"id":"f9047321999d0e29","repo":"dgraph-io/dgraph","slug":"encountered-an-xid-s-with-s-that-isn-t-a-int64-b","errorCode":null,"errorMessage":"encountered an XID %s with %s that isn't a Int64 but data type in schema is Int64","messagePattern":"encountered an XID (.+?) with (.+?) that isn't a Int64 but data type in schema is Int64","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graphql/resolve/mutation_rewriter.go","lineNumber":2472,"sourceCode":"\t\tdefault:\n\t\t\treturn \"\", fmt.Errorf(\"encountered an XID %s with %s that isn't \"+\n\t\t\t\t\"a Int but data type in schema is Int\", xidName, typeName)\n\t\t}\n\tcase \"Int64\":\n\t\tswitch xVal := xidVal.(type) {\n\t\tcase json.Number:\n\t\t\tval, err := xVal.Int64()\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\t\t\treturn strconv.FormatInt(val, 10), nil\n\t\tcase int64:\n\t\t\treturn strconv.FormatInt(xVal, 10), nil\n\t\t// If the xid field is of type Int64, both String and Int forms are allowed.\n\t\tcase string:\n\t\t\treturn xVal, nil\n\t\tdefault:\n\t\t\treturn \"\", fmt.Errorf(\"encountered an XID %s with %s that isn't \"+\n\t\t\t\t\"a Int64 but data type in schema is Int64\", xidName, typeName)\n\t\t}\n\t\t// \"ID\" is given as input for the @extended type mutation.\n\tcase \"String\", \"ID\":\n\t\txidString, ok := xidVal.(string)\n\t\tif !ok {\n\t\t\treturn \"\", fmt.Errorf(\"encountered an XID %s with %s that isn't \"+\n\t\t\t\t\"a String\", xidName, typeName)\n\t\t}\n\t\treturn xidString, nil\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"encountered an XID %s with %s that isn't\"+\n\t\t\t\"allowed as Xid\", xidName, typeName)\n\t}\n}\n\n// This function will return interface type and variable for existence query on interface,\n// if given xid is inherited from interface, otherwise it will return nil and empty string","sourceCodeStart":2454,"sourceCodeEnd":2490,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/graphql/resolve/mutation_rewriter.go#L2454-L2490","documentation":"While extracting an @id (XID) value declared as Int64 in the schema, Dgraph received a runtime type other than json.Number (int) or string. Int64 XIDs intentionally accept both numeric and string forms, but anything else (float, object, bool) fails with this error naming the XID field and schema type.","triggerScenarios":"An add/update mutation supplying a value for an @id field of schema type Int64 whose JSON value is neither an integer nor a string — e.g. a float like 1.5, a boolean, or a nested object.","commonSituations":"Clients sending floats with fractional parts, frameworks serializing IDs as objects or arrays by mistake, or a schema migration changing the field to Int64 while clients still send exotic types.","solutions":["Send the value as a plain integer (12345) or a numeric string (\"12345\") — both are valid for Int64 XIDs.","Remove fractional/decimal parts from the value before sending.","If values can be arbitrary, declare the XID as String in the schema.","Inspect the raw JSON body of the request to confirm the variable's actual type."],"exampleFix":"// before (variables)\n{ \"xid\": 123.45 }\n// after\n{ \"xid\": \"12345\" } // or 12345","handlingStrategy":"type-guard","validationCode":"function assertInt64Xid(v, field) {\n  const ok = typeof v === 'string' || (typeof v === 'number' && Number.isInteger(v));\n  if (!ok) throw new Error(`${field} must be an integer or numeric string for @id(Int64)`);\n  return v;\n}","typeGuard":"function isInt64Compatible(v) {\n  return typeof v === 'string' || (typeof v === 'number' && Number.isInteger(v));\n}","tryCatchPattern":"try {\n  await client.mutate({ mutation: ADD, variables: { input } });\n} catch (e) {\n  if (/isn't a Int64 but data type in schema is Int64/.test(e.message)) {\n    // send as integer or numeric string, then retry\n  } else throw e;\n}","preventionTips":["Send Int64 XIDs as integers or strings only — never floats or booleans.","Round or reject fractional values client-side before mutation.","Validate variable types against the GraphQL operation signature.","Recheck client serializers after migrating a field to Int64."],"tags":["graphql","type-mismatch","id-directive"],"backgroundTag":"xid-type-mismatch","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}