{"record":{"id":"6d1e6c4baf9b7680","repo":"dgraph-io/dgraph","slug":"numpaths-value-d-exceeds-maximum-allowed-value-d","errorCode":null,"errorMessage":"numpaths value %d exceeds maximum allowed value %d","messagePattern":"numpaths value (.+?) exceeds maximum allowed value (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"query/query.go","lineNumber":701,"sourceCode":"\t\targs.AfterUID = after\n\t}\n\n\tif args.Alias == \"shortest\" {\n\t\tif v, ok := gq.Args[\"depth\"]; ok {\n\t\t\tdepth, err := strconv.ParseUint(v, 0, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\targs.ExploreDepth = &depth\n\t\t}\n\n\t\tif v, ok := gq.Args[\"numpaths\"]; ok {\n\t\t\tnumPaths, err := strconv.ParseUint(v, 0, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif numPaths > math.MaxInt {\n\t\t\t\treturn errors.Errorf(\"numpaths value %d exceeds maximum allowed value %d\",\n\t\t\t\t\tnumPaths, math.MaxInt)\n\t\t\t}\n\t\t\targs.NumPaths = int(numPaths)\n\t\t}\n\n\t\tif v, ok := gq.Args[\"maxweight\"]; ok {\n\t\t\tmaxWeight, err := strconv.ParseFloat(v, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\targs.MaxWeight = maxWeight\n\t\t} else if !ok {\n\t\t\targs.MaxWeight = math.MaxFloat64\n\t\t}\n\n\t\tif v, ok := gq.Args[\"minweight\"]; ok {\n\t\t\tminWeight, err := strconv.ParseFloat(v, 64)\n\t\t\tif err != nil {","sourceCodeStart":683,"sourceCodeEnd":719,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/query/query.go#L683-L719","documentation":"The numpaths argument controls how many shortest/recurse paths Dgraph returns. Because paths are stored in Go slices indexed by int, a numpaths larger than math.MaxInt on the platform cannot be represented; fill() parses the value and rejects anything exceeding that bound at parse time rather than overflowing later.","triggerScenarios":"Sending `shortest(from: ..., to: ..., numpaths: 18446744073709551615)` or any value > MaxInt64 on 64-bit (or a huge value like 99999999999999999999 that also fails ParseUint); using numpaths with recurse paths queries.","commonSituations":"Users passing a sentinel \"infinite\" value like 2^64-1 expecting unlimited paths; programmatically generated values from unsigned 64-bit config; copy-paste from docs of large numbers.","solutions":["Lower numpaths to a sane bounded value (e.g. 10, 100) matching what you can consume","Omit numpaths entirely to use the default behavior instead of a huge sentinel","Clamp the value client-side before building the query: min(requested, MaxInt64)"],"exampleFix":"// before\nshortest(from: 0x1, to: 0x2, numpaths: 18446744073709551615)\n// after\nshortest(from: 0x1, to: 0x2, numpaths: 100)","handlingStrategy":"validation","validationCode":"const MAX_NUMPATHS = Number.MAX_SAFE_INTEGER; // aligns with Go math.MaxInt on 64-bit\nfunction setNumPaths(args, n) {\n  if (n > MAX_NUMPATHS) throw new Error('numpaths too large; use a bounded value');\n  args.numpaths = n;\n}","typeGuard":"const isSafeNumPaths = (n) => Number.isInteger(n) && n >= 0 && n <= Number.MAX_SAFE_INTEGER;","tryCatchPattern":"try {\n  await txn.query(q);\n} catch (e) {\n  if (e.message.includes('numpaths value') && e.message.includes('exceeds maximum')) {\n    console.error('Clamp numpaths to a realistic value');\n  }\n  throw e;\n}","preventionTips":["Never use 2^64-1 or other sentinel values for numpaths","Clamp user/config supplied values to a sane upper bound","Omit numpaths when the default is acceptable"],"tags":["dgraph","query","numpaths","out-of-range"],"backgroundTag":"numeric-range-exceeded","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}