AlistGo/alist · error

unexpected copy folder response: status=%d

Error message

unexpected copy folder response: status=%d

What it means

For folder copies the SJTU API returns 202 Accepted with an async task ID (or 409 for merge, handled earlier). This error fires when the folder-copy PUT returned any other status: 401 expired token, 403 permission, 5xx server error, or 201 if the API semantics changed. The status is printed in the message.

Source

Thrown at drivers/sjtu_netdisk/driver.go:544

						Execute(http.MethodPut, childURL); fileErr != nil {
						return nil, fmt.Errorf("copy merge file %s: %w", child.GetName(), fileErr)
					}
				}
			}

			return &model.Object{
				Name:     srcObj.GetName(),
				Size:     srcObj.GetSize(),
				IsFolder: true,
				Modified: srcObj.ModTime(),
				Ctime:    time.Now(),
				Path:     targetPath,
			}, nil
		}

		// 202 Accepted:polling task status
		if resp.StatusCode() != http.StatusAccepted {
			return nil, fmt.Errorf("unexpected copy folder response: status=%d", resp.StatusCode())
		}

		var taskResp TaskInitResp
		if err := json.Unmarshal(resp.Body(), &taskResp); err != nil || taskResp.TaskId == 0 {
			return nil, fmt.Errorf("failed to parse task id: %w", err)
		}

		taskURL := fmt.Sprintf("%s/task/%s/%s/%d", API_URL, d.libraryId, d.spaceId, taskResp.TaskId)
		actualName := srcObj.GetName()
		taskDone := false

		for i := 0; i < 30 && !taskDone; i++ {
			select {
			case <-ctx.Done():
				return nil, ctx.Err()
			case <-time.After(1 * time.Second):
			}

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Map the printed status: 401 → re-save credentials; 403 → check permissions; 5xx → retry later
  2. Verify the destination space is writable and has quota
  3. Retry the copy after re-authentication
  4. If the API changed (e.g. now returns 200/201 with a task body), update the driver's accepted statuses
Defensive patterns

Strategy: try-catch

Try / catch

if err != nil {
    var st int
    if n, _ := fmt.Sscanf(err.Error(), "unexpected copy folder response: status=%d", &st); n == 1 {
        if st == 401 { reauthAndRetry() }
        if st >= 500 { backoffAndRetry() }
    }
}

Prevention

When it happens

Trigger: Executing folder Copy where the PUT /folder/... endpoint responds with a non-202, non-409 status.

Common situations: Token expired before the copy call; no write permission on destination; quota exceeded; upstream API update changing the async-task contract.

Related errors


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