{"record":{"id":"cc58b3938cc6018f","repo":"dgraph-io/dgraph","slug":"can-t-convert-input-to-map-cc58b3","errorCode":null,"errorMessage":"can't convert input to map","messagePattern":"can't convert input to map","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graphql/admin/moveTablet.go","lineNumber":51,"sourceCode":"\tstatus, err := worker.MoveTabletOverNetwork(ctx, &pb.MoveTabletRequest{\n\t\tNamespace: input.Namespace,\n\t\tTablet:    input.Tablet,\n\t\tDstGroup:  input.GroupId,\n\t})\n\tif err != nil {\n\t\treturn resolve.EmptyResult(m, err), false\n\t}\n\n\treturn resolve.DataResult(m,\n\t\tmap[string]interface{}{m.Name(): response(\"Success\", status.GetMsg())},\n\t\tnil,\n\t), true\n}\n\nfunc getMoveTabletInput(m schema.Mutation) (*moveTabletInput, error) {\n\tinputArg, ok := m.ArgValue(schema.InputArgName).(map[string]interface{})\n\tif !ok {\n\t\treturn nil, inputArgError(errors.Errorf(\"can't convert input to map\"))\n\t}\n\n\tinputRef := &moveTabletInput{}\n\t// namespace is an optional parameter\n\tif _, ok = inputArg[\"namespace\"]; !ok {\n\t\tinputRef.Namespace = x.RootNamespace\n\t} else {\n\t\tns, err := parseAsUint64(inputArg[\"namespace\"])\n\t\tif err != nil {\n\t\t\treturn nil, inputArgError(schema.GQLWrapf(err,\n\t\t\t\t\"can't convert input.namespace to uint64\"))\n\t\t}\n\t\tinputRef.Namespace = ns\n\t}\n\n\tinputRef.Tablet, ok = inputArg[\"tablet\"].(string)\n\tif !ok {\n\t\treturn nil, inputArgError(errors.Errorf(\"can't convert input.tablet to string\"))","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/graphql/admin/moveTablet.go#L33-L69","documentation":"getMoveTabletInput extracts the 'input' argument of the moveTablet admin mutation and requires it to arrive as a map[string]interface{} (the shape the GraphQL layer normally produces from a JSON object). If the argument value cannot be type-asserted to a map, this error is returned wrapped by inputArgError. It indicates the mutation was invoked without a properly structured input object.","triggerScenarios":"Calling the moveTablet admin GraphQL mutation with the input argument missing entirely, passed as a scalar/string/JSON blob instead of the declared input object, or via a raw HTTP/client path that bypasses GraphQL variable coercion and hands the resolver a non-map value.","commonSituations":"Hand-crafted admin mutations with a typo like 'inputs:' or 'in:' instead of 'input:', clients sending GraphQL variables with the wrong type (string instead of object), or tooling that posts raw JSON to the admin endpoint without the input wrapper object.","solutions":["Send a properly structured input object: { moveTablet(input: { tablet: \"...\", groupId: 1, namespace: 0 }) }.","If using GraphQL variables, declare $input: MoveTabletInput! and pass a JSON object (not a string) as the variable value.","Check the argument is literally named 'input' (schema.InputArgName) and the type name matches the schema.","Inspect the raw request body to confirm the input field is a JSON object, not a quoted string of JSON.","Regenerate/update the client from the current admin schema in case the mutation signature changed."],"exampleFix":"// before: input as JSON string variable\n{\"query\":\"mutation Move($input: String!){ moveTablet(input: $input){...} }\n// after: typed input object\nmutation Move($input: MoveTabletInput!) { moveTablet(input: $input) { ... } }\n// variables: {\"input\": {\"tablet\":\"5\",\"groupId\":1,\"namespace\":0}}","handlingStrategy":"validation","validationCode":"function assertMoveTabletInput(v) {\n  if (v === null || typeof v !== 'object' || Array.isArray(v)) {\n    throw new Error('moveTablet input must be an object: {tablet, groupId, namespace?}');\n  }\n  return v;\n}","typeGuard":"function isPlainObject(v) {\n  return v !== null && typeof v === 'object' && !Array.isArray(v);\n}","tryCatchPattern":"try {\n  await gql(`mutation Move($input: MoveTabletInput!){ moveTablet(input: $input){...} }`, { input });\n} catch (e) {\n  if (String(e.message).includes(\"can't convert input to map\")) {\n    // input arrived as non-object; rebuild as an object and retry\n  }\n}","preventionTips":["Always pass input as a JSON object, never a stringified JSON string","Declare GraphQL variables with the generated Input! type, not String!","Name the argument exactly 'input'","Test admin mutations in a GraphQL playground before wiring into scripts","Regenerate client SDKs after Dgraph version upgrades"],"tags":["graphql","input-validation","admin-api","mutation"],"backgroundTag":"invalid-graphql-input","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}