{"record":{"id":"9a6196dfe3d7678b","repo":"juicedata/juicefs","slug":"missing-url","errorCode":null,"errorMessage":"missing URL","messagePattern":"missing URL","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdk/java/libjfs/bridge.go","lineNumber":116,"sourceCode":"\tg            prometheus.Gatherer\n\tcommonLabels map[string]string\n}\n\n// Logger is the minimal interface Bridge needs for logging. Note that\n// log.Logger from the standard library implements this interface, and it is\n// easy to implement by custom loggers, if they don't do so already anyway.\ntype Logger interface {\n\tPrintln(v ...interface{})\n}\n\n// NewBridge returns a pointer to a new Bridge struct.\nfunc NewBridge(c *Config) (*Bridge, error) {\n\tb := &Bridge{}\n\n\tb.useTags = c.UseTags\n\n\tif c.URL == \"\" {\n\t\treturn nil, errors.New(\"missing URL\")\n\t}\n\tb.url = c.URL\n\n\tif c.Gatherer == nil {\n\t\tb.g = prometheus.DefaultGatherer\n\t} else {\n\t\tb.g = c.Gatherer\n\t}\n\n\tif c.Logger != nil {\n\t\tb.logger = c.Logger\n\t}\n\n\tif c.Prefix != \"\" {\n\t\tb.prefix = c.Prefix\n\t}\n\n\tvar z time.Duration","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/sdk/java/libjfs/bridge.go#L98-L134","documentation":"NewBridge constructs a metrics Bridge (for the Java SDK's libjfs monitoring) that pushes Prometheus metrics to a push gateway. It returns \"missing URL\" when the supplied Config.URL is the empty string, because without a gateway URL there is nowhere to push metrics.","triggerScenarios":"Calling NewBridge with a *Config whose URL field was never set (zero-value Config), or set to \"\" after skipping validation; callers such as push2Graphite/TestPush construct configs dynamically and an unset variable ends up as the URL.","commonSituations":"Java-side configuration omits the push gateway address, an environment variable feeding the URL is unset, or a refactored constructor path stopped copying the URL field into the Config struct.","solutions":["Set Config.URL to the full push gateway address (e.g. http://host:9091/metrics/job/juicefs) before calling NewBridge.","Validate the URL in the Java layer before entering the bridge so the failure surfaces earlier.","Check the env/config source that feeds the URL for unset or empty values."],"exampleFix":"// before\nb, err := NewBridge(&Config{UseTags: true})\n// after\nb, err := NewBridge(&Config{UseTags: true, URL: \"http://pushgateway:9091/metrics/job/jfs\"})","handlingStrategy":"validation","validationCode":"if cfg.URL == \"\" {\n\treturn fmt.Errorf(\"push gateway URL must be set (Config.URL)\")\n}\n_, err := url.ParseRequestURI(cfg.URL)\nif err != nil {\n\treturn fmt.Errorf(\"invalid push gateway URL %q: %w\", cfg.URL, err)\n}","typeGuard":null,"tryCatchPattern":"b, err := NewBridge(cfg)\nif err != nil {\n\tlog.Fatalf(\"metrics bridge init failed: %v\", err)\n}","preventionTips":["Make URL a required field in whatever struct/env layer builds Config","Fail fast at startup with a clear message if the push gateway endpoint is unset","Check the environment variable feeding the URL is exported in deployment manifests"],"tags":["metrics","configuration","java-sdk"],"backgroundTag":"missing-required-config-field","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}