juicedata/juicefs · error

missing URL

Error message

missing URL

What it means

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.

Source

Thrown at sdk/java/libjfs/remote_write.go:85

// RemoteWriter pushes metrics to the configured remote write endpoint.
type RemoteWriter struct {
	url           string
	gatherer      prometheus.Gatherer
	auth          string
	interval      time.Duration
	timeout       time.Duration
	errorHandling HandlerErrorHandling
	logger        Logger
	commonLabels  map[string]string
	client        *http.Client
}

// NewRemoteWriter returns a pointer to a new RemoteWriter struct.
func NewRemoteWriter(c *RemoteWriteConfig) (*RemoteWriter, error) {
	rw := &RemoteWriter{}

	if c.URL == "" {
		return nil, errors.New("missing URL")
	}
	rw.url = c.URL

	rw.auth = c.Auth

	var z time.Duration
	if c.Interval == z {
		rw.interval = defaultRemoteWriteTimeout
	} else {
		rw.interval = c.Interval
	}

	if c.Timeout == z {
		rw.timeout = defaultRemoteWriteTimeout
	} else {
		rw.timeout = c.Timeout
	}

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Set RemoteWriteConfig.URL to the remote-write endpoint (e.g. http://host:9090/api/v1/write) before constructing the writer.
  2. Validate configuration in the calling (Java) layer so empty URLs are rejected with a clearer message.
  3. Confirm the config source (file/env) actually supplies the endpoint key.

Example fix

// before
w, err := NewRemoteWriter(&RemoteWriteConfig{Auth: auth})
// after
w, err := NewRemoteWriter(&RemoteWriteConfig{URL: "http://prometheus:9090/api/v1/write", Auth: auth})
Defensive patterns

Strategy: validation

Validate before calling

if cfg.URL == "" {
	return fmt.Errorf("remote write URL must be set (RemoteWriteConfig.URL)")
}
if _, err := url.ParseRequestURI(cfg.URL); err != nil {
	return fmt.Errorf("invalid remote write URL %q: %w", cfg.URL, err)
}

Try / catch

w, err := NewRemoteWriter(cfg)
if err != nil {
	log.Fatalf("remote writer init failed: %v", err)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06). Data as JSON: /api/errors/0702cf4640e62129. Report an issue: GitHub.