{"record":{"id":"260a9075ad119f6a","repo":"AlistGo/alist","slug":"unexpected-copy-folder-response-status-d","errorCode":null,"errorMessage":"unexpected copy folder response: status=%d","messagePattern":"unexpected copy folder response: status=(.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/sjtu_netdisk/driver.go","lineNumber":544,"sourceCode":"\t\t\t\t\t\tExecute(http.MethodPut, childURL); fileErr != nil {\n\t\t\t\t\t\treturn nil, fmt.Errorf(\"copy merge file %s: %w\", child.GetName(), fileErr)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn &model.Object{\n\t\t\t\tName:     srcObj.GetName(),\n\t\t\t\tSize:     srcObj.GetSize(),\n\t\t\t\tIsFolder: true,\n\t\t\t\tModified: srcObj.ModTime(),\n\t\t\t\tCtime:    time.Now(),\n\t\t\t\tPath:     targetPath,\n\t\t\t}, nil\n\t\t}\n\n\t\t// 202 Accepted：polling task status\n\t\tif resp.StatusCode() != http.StatusAccepted {\n\t\t\treturn nil, fmt.Errorf(\"unexpected copy folder response: status=%d\", resp.StatusCode())\n\t\t}\n\n\t\tvar taskResp TaskInitResp\n\t\tif err := json.Unmarshal(resp.Body(), &taskResp); err != nil || taskResp.TaskId == 0 {\n\t\t\treturn nil, fmt.Errorf(\"failed to parse task id: %w\", err)\n\t\t}\n\n\t\ttaskURL := fmt.Sprintf(\"%s/task/%s/%s/%d\", API_URL, d.libraryId, d.spaceId, taskResp.TaskId)\n\t\tactualName := srcObj.GetName()\n\t\ttaskDone := false\n\n\t\tfor i := 0; i < 30 && !taskDone; i++ {\n\t\t\tselect {\n\t\t\tcase <-ctx.Done():\n\t\t\t\treturn nil, ctx.Err()\n\t\t\tcase <-time.After(1 * time.Second):\n\t\t\t}\n","sourceCodeStart":526,"sourceCodeEnd":562,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/sjtu_netdisk/driver.go#L526-L562","documentation":"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.","triggerScenarios":"Executing folder Copy where the PUT /folder/... endpoint responds with a non-202, non-409 status.","commonSituations":"Token expired before the copy call; no write permission on destination; quota exceeded; upstream API update changing the async-task contract.","solutions":["Map the printed status: 401 → re-save credentials; 403 → check permissions; 5xx → retry later","Verify the destination space is writable and has quota","Retry the copy after re-authentication","If the API changed (e.g. now returns 200/201 with a task body), update the driver's accepted statuses"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err != nil {\n    var st int\n    if n, _ := fmt.Sscanf(err.Error(), \"unexpected copy folder response: status=%d\", &st); n == 1 {\n        if st == 401 { reauthAndRetry() }\n        if st >= 500 { backoffAndRetry() }\n    }\n}","preventionTips":["Verify write permission and quota on the destination before folder copies","Keep the token fresh so 401 never reaches the copy call","Retry 5xx with backoff; report repeated unexpected statuses upstream"],"tags":["sjtu-netdisk","copy","http","async-task"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}