{"record":{"id":"56f090ffc006c11d","repo":"dgraph-io/dgraph","slug":"can-t-convert-input-what-to-string","errorCode":null,"errorMessage":"can't convert input.what to string","messagePattern":"can't convert input\\.what to string","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graphql/admin/assign.go","lineNumber":86,"sourceCode":"\t\t\t\t\"startId\":  startId,\n\t\t\t\t\"endId\":    endId,\n\t\t\t\t\"readOnly\": readOnly,\n\t\t\t},\n\t\t}},\n\t\tnil,\n\t), true\n}\n\nfunc getAssignInput(m schema.Mutation) (*assignInput, 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 := &assignInput{}\n\tinputRef.What, ok = inputArg[\"what\"].(string)\n\tif !ok {\n\t\treturn nil, inputArgError(errors.Errorf(\"can't convert input.what to string\"))\n\t}\n\n\tnum, err := parseAsUint64(inputArg[\"num\"])\n\tif err != nil {\n\t\treturn nil, inputArgError(schema.GQLWrapf(err, \"can't convert input.num to uint64\"))\n\t}\n\tinputRef.Num = num\n\n\treturn inputRef, nil\n}\n","sourceCodeStart":68,"sourceCodeEnd":97,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/graphql/admin/assign.go#L68-L97","documentation":"getAssignInput reads input.what from the assign mutation input and requires it to be a string (the kind of value to assign, e.g. \"uids\"). A missing or non-string 'what' key produces this inputArgError.","triggerScenarios":"assignDgraphMutation input object without a 'what' field, or with a non-string value (number, object, enum passed as non-string) at graphql/admin/assign.go:86.","commonSituations":"Omitting 'what' in hand-written payloads; confusing the enum-like value and sending an integer; older clients using a removed field name (e.g. 'type') instead of 'what'.","solutions":["Add or fix input.what as a string, e.g. {\"what\": \"uids\", \"num\": 100}.","Check the mutation schema (assignDgraphMutation input type) for the exact field name and type.","Validate the payload JSON before sending."],"exampleFix":"// before\n{\"what\": 3, \"num\": 100}\n// after\n{\"what\": \"uids\", \"num\": 100}","handlingStrategy":"type-guard","validationCode":"function requireAssignWhat(input) {\n  if (typeof input?.what !== 'string') throw new Error(\"input.what must be a string, e.g. 'uids'\");\n}","typeGuard":"function hasStringWhat(v) { return typeof v === 'object' && v !== null && typeof v.what === 'string' && v.what.length > 0; }","tryCatchPattern":"try { await assign(input); } catch (e) { if (String(e).includes(\"can't convert input.what to string\")) { throw new Error('Missing or non-string input.what in assign mutation'); } throw e; }","preventionTips":["Always include what: \"uids\" (or the intended kind) in assign input","Keep client types in sync with the assignDgraphMutation input type","Unit-test mutation payload builders"],"tags":["graphql","mutation","input-validation","assign"],"backgroundTag":"invalid-mutation-input","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}