{"record":{"id":"fb200015f4254941","repo":"dgraph-io/dgraph","slug":"got-unexpected-value-type","errorCode":null,"errorMessage":"got unexpected value type","messagePattern":"got unexpected value type","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graphql/admin/removeNode.go","lineNumber":86,"sourceCode":"\treturn parseAsUint(val, 64)\n}\n\nfunc parseAsUint32(val interface{}) (uint32, error) {\n\tret, err := parseAsUint(val, 32)\n\treturn uint32(ret), err\n}\n\nfunc parseAsUint(val interface{}, bitSize int) (uint64, error) {\n\tret := uint64(0)\n\tvar err error\n\n\tswitch v := val.(type) {\n\tcase string:\n\t\tret, err = strconv.ParseUint(v, 10, bitSize)\n\tcase json.Number:\n\t\tret, err = strconv.ParseUint(v.String(), 10, bitSize)\n\tdefault:\n\t\terr = errors.Errorf(\"got unexpected value type\")\n\t}\n\n\treturn ret, err\n}\n","sourceCodeStart":68,"sourceCodeEnd":91,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/graphql/admin/removeNode.go#L68-L91","documentation":"parseAsUint is the shared integer parser for removeNode's nodeId/groupId fields; it only accepts string and json.Number values and parses them with strconv.ParseUint. Any other JSON type (float64, bool, nil, object) lands in the default branch and produces this generic 'got unexpected value type' error, wrapped by callers into 'can't convert input.nodeId to uint64' etc.","triggerScenarios":"Passing nodeId (or groupId) to removeNode as a JSON float/bool/null/object rather than a numeric string or json.Number; this happens when a client sends {\"nodeId\": null} or a nested value, or when custom middleware re-parses variables with a decoder producing float64 in a code path that skips the string/Number cases.","commonSituations":"Null fields from partially-built clients, IDs sourced from databases/JSON APIs as floats, or template interpolations yielding 'null' or objects. Also occurs with JS clients serializing large IDs imprecisely then falling into alternate shapes.","solutions":["Send nodeId/groupId as a JSON number or numeric string: {\"nodeId\": \"1\"} or {\"nodeId\": 1}.","Ensure the fields are present and non-null; remove them only if the schema marks them optional and you intend to omit them.","If values originate from external JSON, coerce before sending: String(Math.trunc(id)) in JS or fmt.Sprintf(\"%d\", v) in Go.","Check the wrapped outer message to see which field (nodeId vs groupId) triggered it.","Avoid re-parsing GraphQL variables with encoders that emit non-standard types."],"exampleFix":"// before\n{\"input\": {\"nodeId\": null}}\n// after\n{\"input\": {\"nodeId\": \"1\"}}","handlingStrategy":"type-guard","validationCode":"function assertNodeId(v) {\n  const n = typeof v === 'string' ? v : (typeof v === 'number' && Number.isInteger(v) ? String(v) : null);\n  if (n === null || !/^\\d+$/.test(n)) throw new Error('nodeId must be a numeric string or integer');\n  return n;\n}","typeGuard":"function isUintLike(v) {\n  return (typeof v === 'string' && /^\\d+$/.test(v)) ||\n         (typeof v === 'number' && Number.isInteger(v) && v >= 0);\n}","tryCatchPattern":"try {\n  await gql(removeNodeMutation, { input: { nodeId: assertNodeId(nodeId) } });\n} catch (e) {\n  if (/unexpected value type|can't convert input\\.(nodeId|groupId)/.test(e.message)) {\n    // normalize the offending field to a numeric string and retry\n  }\n}","preventionTips":["Send IDs as integers or numeric strings, never null/bool/objects","Sanitize IDs coming from external JSON APIs before sending","Validate with a regex like /^\\d+$/ client-side","Keep IDs under uint64 range (avoid > 2^64-1)","Check the outer wrapped message to identify which field failed"],"tags":["graphql","type-mismatch","input-validation","parsing"],"backgroundTag":"invalid-graphql-input","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}