AlistGo/alist · error

unexpected rename folder response: status=%d

Error message

unexpected rename folder response: status=%d

What it means

The SJTU driver's folder Rename got a response status it does not recognize: not the success it checks earlier, not 409 (handled as merge), and whatever status was returned falls through to this error. The status code is printed, so the failure is identifiable from the message alone.

Source

Thrown at drivers/sjtu_netdisk/driver.go:437

					if fileErr != nil {
						return nil, fmt.Errorf("rename merge file %s: %w", child.GetName(), fileErr)
					}
				}
			}

			_ = d.Remove(ctx, srcObj)

			return &model.Object{
				Name:     newName,
				Size:     srcObj.GetSize(),
				IsFolder: true,
				Modified: srcObj.ModTime(),
				Ctime:    srcObj.CreateTime(),
				Path:     dstPath,
			}, nil
		}

		return nil, fmt.Errorf("unexpected rename folder response: status=%d", resp.StatusCode())
	}
}

func (d *SJTUNetdisk) Copy(ctx context.Context, srcObj, dstDir model.Obj) (model.Obj, error) {
	if err := d.refreshToken(ctx); err != nil {
		return nil, err
	}

	srcPath := srcObj.GetPath()
	targetPath := path.Join(dstDir.GetPath(), srcObj.GetName())

	// file copy
	if !srcObj.IsDir() {
		copyURL := fmt.Sprintf("%s/file/%s/%s/%s", API_URL, d.libraryId, d.spaceId, d.encodePath(targetPath))

		var copyResp MoveCopyResp
		_, err := d.newClient().R().
			SetContext(ctx).

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Match the printed status: 401 → re-save credentials; 403 → check space permissions; 404 → refresh, the folder is gone; 5xx → retry later
  2. Confirm the rename works in the official SJTU client
  3. Re-authenticate the driver and retry
  4. Report persistent unknown statuses as a driver issue with the status code
Defensive patterns

Strategy: try-catch

Try / catch

if err != nil {
    var st int
    if n, _ := fmt.Sscanf(err.Error(), "unexpected rename folder response: status=%d", &st); n == 1 {
        switch {
        case st == 401: reauthAndRetry()
        case st == 404: refreshListing()
        default: return err
        }
    }
}

Prevention

When it happens

Trigger: Rename folder PUT returns 401 (expired token), 403 (no permission), 404 (source missing), or 5xx — none of which are handled branches.

Common situations: Token expired before the rename call; renaming a folder that was deleted elsewhere; write permission lost on the space; upstream API change adding a new required parameter.

Related errors


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