{"record":{"id":"651aadd01a07ac81","repo":"dgraph-io/dgraph","slug":"no-value-found","errorCode":null,"errorMessage":"No value found","messagePattern":"No value found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dql/parser.go","lineNumber":312,"sourceCode":"\tvm = make(map[string]varInfo)\n\tfor k, v := range variables {\n\t\tvm[k] = varInfo{\n\t\t\tValue: v,\n\t\t}\n\t}\n\treturn vm\n}\n\n// Request stores the query text and the variable mapping.\ntype Request struct {\n\tStr       string\n\tVariables map[string]string\n}\n\nfunc parseValue(v varInfo) (types.Val, error) {\n\ttyp := v.Type\n\tif v.Value == \"\" {\n\t\treturn types.Val{}, errors.Errorf(\"No value found\")\n\t}\n\n\tswitch typ {\n\tcase \"int\":\n\t\t{\n\t\t\tif i, err := strconv.ParseInt(v.Value, 0, 64); err != nil {\n\t\t\t\treturn types.Val{}, errors.Wrapf(err, \"Expected an int but got %v\", v.Value)\n\t\t\t} else {\n\t\t\t\treturn types.Val{\n\t\t\t\t\tTid:   types.IntID,\n\t\t\t\t\tValue: i,\n\t\t\t\t}, nil\n\t\t\t}\n\t\t}\n\tcase \"float\":\n\t\t{\n\t\t\tif i, err := strconv.ParseFloat(v.Value, 64); err != nil {\n\t\t\t\treturn types.Val{}, errors.Wrapf(err, \"Expected a float but got %v\", v.Value)","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/dql/parser.go#L294-L330","documentation":"parseValue converts a query variable (varInfo with Type and Value) into a typed types.Val. If the variable's Value string is empty there is nothing to parse, so the library returns 'No value found' immediately, before any type-specific parsing.","triggerScenarios":"Calling parseValue (reached via ParseWithNeedVars) with a variable map entry whose value is the empty string, e.g. $name=\"\" supplied in the variables map of a parameterized DQL query.","commonSituations":"Client code builds the variables map from user input or env and the value is unset; template string substitution leaves a variable empty; forgetting to include a required variable so the resolver fills an empty string.","solutions":["Validate all variable values are non-empty strings before calling the parse/mutation API with the variables map","Provide a default value for optional variables on the client side","Check where the variables map is populated (env vars, request params) for empty inputs and reject them early"],"exampleFix":"// before\nvars := map[string]string{\"$name\": req.Name} // may be \"\"\n// after\nif req.Name == \"\" { return errors.New(\"$name is required\") }\nvars := map[string]string{\"$name\": req.Name}","handlingStrategy":"validation","validationCode":"for k, v := range vars {\n  if v == \"\" { return fmt.Errorf(\"variable %s has empty value\", k) }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate the variables map before every parameterized query","Reject empty user/env inputs at the boundary instead of passing them through","Use distinct sentinel handling for optional variables rather than empty strings"],"tags":["dgraph","dql","variables","validation"],"backgroundTag":"empty-query-variable","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}