AlistGo/alist · error

resp.String()

Error message

resp.String()

What it means

CloudreveV4 request helper returns this when the HTTP response status is not 2xx, before any JSON envelope parsing. resp.String() dumps the whole response body — often an HTML error page from a reverse proxy, a 404 from a wrong base URL, or a gateway timeout page.

Source

Thrown at drivers/cloudreve_v4/util.go:62

		"User-Agent": d.getUA(),
	})
	if d.AccessToken != "" {
		req.SetHeader("Authorization", "Bearer "+d.AccessToken)
	}

	var r Resp
	req.SetResult(&r)

	if callback != nil {
		callback(req)
	}

	resp, err := req.Execute(method, u)
	if err != nil {
		return err
	}
	if !resp.IsSuccess() {
		return errors.New(resp.String())
	}

	if r.Code != 0 {
		if r.Code == 401 && d.RefreshToken != "" && path != "/session/token/refresh" {
			// try to refresh token
			err = d.refreshToken()
			if err != nil {
				return err
			}
			return d.request(method, path, callback, out)
		}
		return errors.New(r.Msg)
	}

	if out != nil && r.Data != nil {
		var marshal []byte
		marshal, err = json.Marshal(r.Data)
		if err != nil {

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Confirm the address points to a real Cloudreve V4 instance (check /api/v4/site/config/login responds).
  2. Fix scheme/host/port in the storage addition; avoid trailing slash or path suffixes unless required.
  3. If a reverse proxy fronts the instance, ensure it forwards to the correct upstream and does not intercept API routes.
  4. Read the body inside the error — it identifies whether the failure is from Cloudrebve, the proxy, or a CDN.

Example fix

# before: address = https://demo.cloudreve.org (V3 site)
# after:  address = https://v4.example.com   (actual Cloudreve V4 deployment)
curl -sS https://v4.example.com/api/v4/site/config/login
Defensive patterns

Strategy: validation

Validate before calling

// verify the base URL is a live CloudreveV4 API before any storage op
probe, err := http.NewRequest(http.MethodGet, address+"/api/v4/site/config/login", nil)
if err != nil { return err }
res, err := base.HttpClient.Do(probe)
if err != nil || res.StatusCode != 200 { return errors.New("address is not a Cloudreve V4 endpoint") }

Type guard

func isHttpFailure(err error) bool {
    return err != nil && (strings.Contains(err.Error(), "404") || strings.Contains(err.Error(), "502") || strings.Contains(err.Error(), "<html"))
}

Try / catch

if err := d.request(...); err != nil {
    if strings.Contains(err.Error(), "<html") { // proxy error page, not API JSON
        return fmt.Errorf("non-JSON response from %s — check address/reverse proxy: %w", d.Address, err)
    }
    return err
}

Prevention

When it happens

Trigger: req.Execute(method, u) completes but resp.IsSuccess() is false. Caused by wrong site address in the driver addition, Cloudrebve V4 not actually running V4 API routes, 5xx from upstream, or auth middleware rejecting with non-JSON.

Common situations: Driver pointed at a Cloudrebve V3 instance (different API paths) while using the V4 driver; trailing path/scheme mistakes in the address field; reverse proxy returning 502/504 HTML; maintenance mode enabled on the site.

Related errors


AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15). Data as JSON: /api/errors/d95e80b2fa86f05d. Report an issue: GitHub.