juicedata/juicefs · error

bad response status %s

Error message

bad response status %s

What it means

The dragonfly object storage driver's Create uploads an object via HTTP and treats any response whose status code is not 2xx as a failure, returning "bad response status %s" with the raw status line (e.g. "502 Bad Gateway"). The server accepted the request but refused or failed the upload.

Source

Thrown at pkg/object/dragonfly.go:206

	}

	u.Path = path.Join("buckets", d.bucket)
	query := u.Query()
	u.RawQuery = query.Encode()
	req, err := http.NewRequestWithContext(ctx, http.MethodPost, u.String(), nil)
	if err != nil && !isExists(err) {
		return err
	}
	setUserAgent(req)

	resp, err := d.client.Do(req)
	if err != nil {
		return err
	}
	defer resp.Body.Close()

	if resp.StatusCode/100 != 2 {
		return fmt.Errorf("bad response status %s", resp.Status)
	}

	return nil
}

// Head returns the object metadata if it exists.
func (d *dragonfly) Head(ctx context.Context, key string) (Object, error) {
	// get get object metadata request.
	u, err := url.Parse(d.endpoint)
	if err != nil {
		return nil, err
	}

	u.Path = path.Join("buckets", d.bucket, "objects", key)
	if strings.HasSuffix(key, "/") {
		u.Path += "/"
	}

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Check the returned status string in the error and inspect dragonfly server/dfdaemon logs for the corresponding request.
  2. Verify the endpoint host:port points to a live dragonfly service (curl the URL manually).
  3. Fix authentication/permission settings if the status is 401/403; check upstream proxies if 502/504.
  4. Retry the upload once server-side issues (5xx) are resolved — the driver surfaces the status but does not retry.

Example fix

// before
// endpoint misconfigured to wrong port
url := "http://127.0.0.1:65001/objects/key"
// after
url := "http://127.0.0.1:8000/objects/key" // correct dfdaemon port
Defensive patterns

Strategy: retry

Validate before calling

resp, err := http.Head(dragonflyBaseURL + "/health")
if err != nil || resp.StatusCode/100 != 2 {
    return fmt.Errorf("dragonfly endpoint %s not healthy before upload", dragonflyBaseURL)
}

Try / catch

err := store.Create(ctx, key, data)
if err != nil && strings.Contains(err.Error(), "bad response status") {
    if strings.Contains(err.Error(), "50") { // 5xx: transient, retry with backoff
        err = retryWithBackoff(func() error { return store.Create(ctx, key, data) })
    }
}

Prevention

When it happens

Trigger: Uploading (Create/PUT) to a Dragonfly endpoint (e.g. http://host:8000/...) that responds with 4xx/5xx — 403 auth, 404 unknown peer/path, 500 server error, 502/504 proxy errors.

Common situations: Dragonfly dfdaemon/peer not running or wrong port; proxy/LB returning 502; bucket/path permissions misconfigured; disk full on the dragonfly node; version mismatch causing unsupported API paths.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


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