{"record":{"id":"0702cf4640e62129","repo":"juicedata/juicefs","slug":"missing-url-0702cf","errorCode":null,"errorMessage":"missing URL","messagePattern":"missing URL","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdk/java/libjfs/remote_write.go","lineNumber":85,"sourceCode":"// RemoteWriter pushes metrics to the configured remote write endpoint.\ntype RemoteWriter struct {\n\turl           string\n\tgatherer      prometheus.Gatherer\n\tauth          string\n\tinterval      time.Duration\n\ttimeout       time.Duration\n\terrorHandling HandlerErrorHandling\n\tlogger        Logger\n\tcommonLabels  map[string]string\n\tclient        *http.Client\n}\n\n// NewRemoteWriter returns a pointer to a new RemoteWriter struct.\nfunc NewRemoteWriter(c *RemoteWriteConfig) (*RemoteWriter, error) {\n\trw := &RemoteWriter{}\n\n\tif c.URL == \"\" {\n\t\treturn nil, errors.New(\"missing URL\")\n\t}\n\trw.url = c.URL\n\n\trw.auth = c.Auth\n\n\tvar z time.Duration\n\tif c.Interval == z {\n\t\trw.interval = defaultRemoteWriteTimeout\n\t} else {\n\t\trw.interval = c.Interval\n\t}\n\n\tif c.Timeout == z {\n\t\trw.timeout = defaultRemoteWriteTimeout\n\t} else {\n\t\trw.timeout = c.Timeout\n\t}\n","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/sdk/java/libjfs/remote_write.go#L67-L103","documentation":"NewRemoteWriter creates a Prometheus remote-write client for the Java SDK's metrics. It returns \"missing URL\" when RemoteWriteConfig.URL is empty, since the writer has no remote endpoint to POST samples to.","triggerScenarios":"Calling NewRemoteWriter (directly or via push2RemoteWrite) with a RemoteWriteConfig whose URL field is the zero value — never set, or set to \"\" from an unset config/env variable.","commonSituations":"Remote-write endpoint not configured in the Java client's properties, an environment variable holding the endpoint is missing, or programmatic construction of RemoteWriteConfig skipped the URL field.","solutions":["Set RemoteWriteConfig.URL to the remote-write endpoint (e.g. http://host:9090/api/v1/write) before constructing the writer.","Validate configuration in the calling (Java) layer so empty URLs are rejected with a clearer message.","Confirm the config source (file/env) actually supplies the endpoint key."],"exampleFix":"// before\nw, err := NewRemoteWriter(&RemoteWriteConfig{Auth: auth})\n// after\nw, err := NewRemoteWriter(&RemoteWriteConfig{URL: \"http://prometheus:9090/api/v1/write\", Auth: auth})","handlingStrategy":"validation","validationCode":"if cfg.URL == \"\" {\n\treturn fmt.Errorf(\"remote write URL must be set (RemoteWriteConfig.URL)\")\n}\nif _, err := url.ParseRequestURI(cfg.URL); err != nil {\n\treturn fmt.Errorf(\"invalid remote write URL %q: %w\", cfg.URL, err)\n}","typeGuard":null,"tryCatchPattern":"w, err := NewRemoteWriter(cfg)\nif err != nil {\n\tlog.Fatalf(\"remote writer init failed: %v\", err)\n}","preventionTips":["Treat the remote-write endpoint as mandatory config and validate before constructing the writer","Verify the endpoint key exists in your properties/env before the Java bridge starts","Keep a startup self-check that pushes one test sample to confirm the URL works"],"tags":["metrics","configuration","java-sdk","remote-write"],"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"}