AlistGo/alist · error

remove failed: status=%d

Error message

remove failed: status=%d

What it means

Thrown by the SJTU driver's Remove when the DELETE call does not return a 2xx status. The status code is printed. Because permanent=0 is requested, the item goes to the recycle bin; failures usually mean auth, permission, or the item already being gone in an unexpected way.

Source

Thrown at drivers/sjtu_netdisk/driver.go:624

		endpoint = "directory"
	} else {
		endpoint = "file"
	}

	removeURL := fmt.Sprintf("%s/%s/%s/%s/%s", API_URL, endpoint, d.libraryId, d.spaceId, d.encodePath(obj.GetPath()))
	resp, err := d.newClient().R().
		SetContext(ctx).
		SetQueryParam("access_token", d.accessToken).
		SetQueryParam("permanent", "0").
		SetQueryParam("space_org_id", "1").
		Execute(http.MethodDelete, removeURL)

	if err != nil {
		return err
	}

	if resp.StatusCode() < 200 || resp.StatusCode() >= 300 {
		return fmt.Errorf("remove failed: status=%d", resp.StatusCode())
	}

	return nil
}

func (d *SJTUNetdisk) Put(ctx context.Context, dstDir model.Obj, stream model.FileStreamer, up driver.UpdateProgress) (model.Obj, error) {
	if err := d.refreshToken(ctx); err != nil {
		return nil, err
	}

	parentPath := strings.TrimPrefix(strings.ReplaceAll(dstDir.GetPath(), "\\", "/"), "/")

	// step 1: apply for confirm key
	initURL := fmt.Sprintf("%s/file/%s/%s/%s", API_URL, d.libraryId, d.spaceId, d.encodePath(buildPath(parentPath, stream.GetName())))

	mainClient := d.newClient()

	var initResp UploadInitResp

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Map the printed status: 401 → re-save credentials; 403 → verify delete permission; 5xx → retry
  2. Refresh the directory listing — if the item is already gone, the error is moot
  3. Retry the delete once after re-authentication
  4. Confirm deletion works in the official SJTU client
Defensive patterns

Strategy: try-catch

Try / catch

if err != nil {
    var st int
    if n, _ := fmt.Sscanf(err.Error(), "remove failed: status=%d", &st); n == 1 {
        if st == 401 { reauthAndRetry() }
        if st >= 500 { backoffAndRetry() }
        if st == 404 { return nil } // already gone
    }
}

Prevention

When it happens

Trigger: Deleting a file/folder with an expired access_token (401), no delete permission (403), or a server error (5xx).

Common situations: Token expired before the delete; deleting an item already removed by another client (server may not return 2xx); read-only shared space.

Related errors


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