{"record":{"id":"56a4e6367b5af802","repo":"googleapis/mcp-toolbox","slug":"dgraph-url-should-not-be-empty","errorCode":null,"errorMessage":"dgraph url should not be empty","messagePattern":"dgraph url should not be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/dgraph/dgraph.go","lineNumber":150,"sourceCode":"\n\tvar result struct {\n\t\tData map[string]interface{} `json:\"data\"`\n\t}\n\n\tif err := json.Unmarshal(resp, &result); err != nil {\n\t\treturn nil, fmt.Errorf(\"error parsing JSON: %v\", err)\n\t}\n\n\treturn result.Data, nil\n}\n\nfunc initDgraphHttpClient(ctx context.Context, tracer trace.Tracer, r Config) (*DgraphClient, error) {\n\t//nolint:all // Reassigned ctx\n\tctx, span := sources.InitConnectionSpan(ctx, tracer, SourceType, r.Name)\n\tdefer span.End()\n\n\tif r.DgraphUrl == \"\" {\n\t\treturn nil, fmt.Errorf(\"dgraph url should not be empty\")\n\t}\n\n\thc := &DgraphClient{\n\t\thttpClient: &http.Client{},\n\t\tbaseUrl:    r.DgraphUrl,\n\t\tHttpToken: &HttpToken{\n\t\t\tUserId:    r.User,\n\t\t\tNamespace: r.Namespace,\n\t\t\tPassword:  r.Password,\n\t\t},\n\t\tapiKey: r.ApiKey,\n\t}\n\n\tif r.User != \"\" || r.Password != \"\" {\n\t\tif err := hc.loginWithCredentials(); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/dgraph/dgraph.go#L132-L168","documentation":"initDgraphHttpClient validates the source Config during Initialize and rejects an empty DgraphUrl with this sentinel error. The Dgraph client cannot function without a base URL, so initialization fails fast rather than erroring per-request.","triggerScenarios":"Initializing a Dgraph source whose YAML/config omits the dgraphUrl field or sets it to an empty string.","commonSituations":"Missing key in the tools YAML config, wrong YAML field name (e.g. 'url' instead of 'dgraphUrl'), environment substitution producing an empty value.","solutions":["Set dgraphUrl in the source config, e.g. dgraphUrl: http://localhost:8080","Check the YAML key spelling and indentation in the toolbox config","If using env substitution, confirm the environment variable is set in the runtime environment","Validate the config before starting the toolbox"],"exampleFix":"// before\nsources:\n  my-dgraph:\n    kind: dgraph\n// after\nsources:\n  my-dgraph:\n    kind: dgraph\n    dgraphUrl: http://localhost:8080","handlingStrategy":"validation","validationCode":"cfg := dgraph.Config()\nif cfg.DgraphUrl == \"\" {\n\treturn fmt.Errorf(\"dgraph source %q: dgraphUrl must be set, e.g. http://localhost:8080\", cfg.Name)\n}\nif u, err := url.Parse(cfg.DgraphUrl); err != nil || u.Host == \"\" {\n\treturn fmt.Errorf(\"dgraphUrl is not a valid URL: %q\", cfg.DgraphUrl)\n}","typeGuard":null,"tryCatchPattern":"if err := toolbox.Start(ctx); err != nil {\n\tif strings.Contains(err.Error(), \"dgraph url should not be empty\") {\n\t\t// fix the dgraph source config before restarting\n\t}\n}","preventionTips":["Always set dgraphUrl in the dgraph source YAML block","Validate toolbox configs with a schema/linter before deployment","Check env-substituted values resolve at runtime, not just locally"],"tags":["dgraph","configuration","missing-config","startup"],"backgroundTag":"missing-config-value","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}