AlistGo/alist · error

request failed

Error message

request failed: %s

What it means

Thrown by the Seafile driver's request helper after the response status is >= 400. The helper first retries once on 401 by re-fetching an auth token, so any other 4xx/5xx (or a 401 that survived the token refresh) reaches this check. The message embeds the full response body, so the Seafile server's own error text is included.

Solutions

  1. Read the response body inside the error text — Seafile usually states the exact cause (e.g. 'Library not found', 'Incorrect password')
  2. Verify the Addition config: server address, repo ID (36-char UUID or library name), username and password/token
  3. Re-enter credentials so a fresh token is obtained, then retry the operation
  4. Confirm the account still has access to the target library on the Seafile web UI
  5. Check the reverse proxy / Seafile server logs if the body shows 5xx or an HTML error page

Example fix

// before: opaque failure
err := d.request(ctx, url)
// after: surface status + body for diagnosis
if res.StatusCode() >= 400 {
    return nil, fmt.Errorf("request failed: status=%d body=%s", res.StatusCode(), res.String())
}
Defensive patterns

Strategy: retry

Try / catch

err := doSeafileOp()
if err != nil {
    if strings.Contains(err.Error(), "request failed:") {
        // body text from Seafile is embedded; branch on 'Unauthorized'/'not found'
        if strings.Contains(err.Error(), "Unauthorized") { refreshCreds(); retry() }
    }
}

Prevention

When it happens

Trigger: Any Seafile API call (listing, upload, link, delete) whose response code is >= 400: expired or invalid token whose getToken() refresh also fails or returns a token the server still rejects (401 twice), a library/repo ID that no longer exists (404), permission denied (403), or a Seafile server-side 5xx.

Common situations: Wrong Seafile server URL or repository ID in the mount config; password/token changed or revoked since it was saved; the account lost access to the library; Seafile server upgraded and the API endpoint moved; reverse proxy in front of Seafile returning HTML error pages.

Related errors


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

Appendix: source

Thrown at drivers/seafile/util.go:68

	var (
		res *resty.Response
		err error
	)
	for i := 0; i < 2; i++ {
		res, err = req.Execute(method, full)
		if err != nil {
			return nil, err
		}
		if res.StatusCode() != 401 { // Unauthorized
			break
		}
		err = d.getToken()
		if err != nil {
			return nil, err
		}
	}
	if res.StatusCode() >= 400 {
		return nil, fmt.Errorf("request failed: %s", res.String())
	}
	return res.Body(), nil
}

func (d *Seafile) getRepoAndPath(fullPath string) (repo *LibraryInfo, path string, err error) {
	libraryMap := d.libraryMap
	repoId := d.Addition.RepoId
	if repoId != "" {
		if len(repoId) == 36 /* uuid */ {
			for _, library := range libraryMap {
				if library.Id == repoId {
					return library, fullPath, nil
				}
			}
		}
	} else {
		var repoName string
		str := fullPath[1:]

View on GitHub (pinned to 843d9dc814)