{"record":{"id":"c6e4f87594092fae","repo":"dgraph-io/dgraph","slug":"while-substituting-vars-in-url","errorCode":null,"errorMessage":"while substituting vars in URL","messagePattern":"while substituting vars in URL","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graphql/schema/wrappers.go","lineNumber":1569,"sourceCode":"\t\tfconf.RemoteGqlQueryName = qfield.Name\n\t\tbuf := &bytes.Buffer{}\n\t\tbuildGraphqlRequestFields(buf, f.field)\n\t\tremoteQuery := graphqlArg.Raw\n\t\tremoteQuery = remoteQuery[:strings.LastIndex(remoteQuery, \"}\")]\n\t\tremoteQuery = fmt.Sprintf(\"%s%s}\", remoteQuery, buf.String())\n\t\tfconf.RemoteGqlQuery = remoteQuery\n\t}\n\n\t// if it is a query or mutation, substitute the vars in URL and Body here itself\n\tif isQueryOrMutation {\n\t\tvar err error\n\t\targMap := f.field.ArgumentMap(f.op.vars)\n\t\tvar bodyVars map[string]interface{}\n\t\t// url params can exist only with body, and not with graphql\n\t\tif graphqlArg == nil {\n\t\t\tfconf.URL, err = SubstituteVarsInURL(fconf.URL, argMap)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errors.Wrapf(err, \"while substituting vars in URL\")\n\t\t\t}\n\t\t\tbodyVars = argMap\n\t\t} else {\n\t\t\tbodyVars = make(map[string]interface{})\n\t\t\tbodyVars[\"query\"] = fconf.RemoteGqlQuery\n\t\t\tbodyVars[\"variables\"] = argMap\n\t\t}\n\t\tfconf.Template = SubstituteVarsInBody(fconf.Template, bodyVars)\n\t}\n\treturn fconf, nil\n}\n\nfunc (f *field) CustomHTTPConfig() (*FieldHTTPConfig, error) {\n\treturn getCustomHTTPConfig(f, false)\n}\n\nfunc (f *field) EnumValues() []string {\n\ttyp := f.Type()","sourceCodeStart":1551,"sourceCodeEnd":1587,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/graphql/schema/wrappers.go#L1551-L1587","documentation":"When resolving a field backed by a remote (federation/custom) GraphQL endpoint, URL template variables in fconf.URL are substituted from the field's argument map via SubstituteVarsInURL. This error is wrapped when that substitution fails — typically because a required URL variable has no matching argument value.","triggerScenarios":"Executing a query whose remote resolution config has a URL with `{{var}}` placeholders while graphqlArg is nil, and argMap lacks the variable or the value is incompatible with substitution.","commonSituations":"RemoteGraphQL URL templating mismatched with the field's arguments; renaming an argument without updating the URL template; nil/missing argument values at query time.","solutions":["Ensure every `{{var}}` in the remote URL matches a field argument name","Check the wrapped error for which variable failed to substitute","Fix the @remote/custom config so URL params align with the schema arguments"],"exampleFix":"// before\nurl: \"http://svc:8080/product/{{id}\"\n// after\nurl: \"http://svc:8080/product/{{id}}\"","handlingStrategy":"validation","validationCode":"vars := regexp.MustCompile(`\\{\\{([^}]+)\\}\\}`).FindAllStringSubmatch(conf.URL, -1)\nfor _, v := range vars {\n\tif _, ok := args[v[1]]; !ok { return fmt.Errorf(\"missing URL var %s\", v[1]) }\n}","typeGuard":null,"tryCatchPattern":"res, err := field.Resolve(...)\nif err != nil && strings.Contains(err.Error(), \"while substituting vars in URL\") {\n\tlog.Errorf(\"remote URL template vars mismatch: %v\", err)\n\treturn nil, err\n}","preventionTips":["Keep remote URL templates in sync with schema argument names","Test remote resolution configs with representative queries before deploy","Avoid optional URL variables; give every placeholder a guaranteed argument"],"tags":["graphql","remote-resolver","url","configuration"],"backgroundTag":"url-variable-substitution-failed","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}