{"record":{"id":"56f476168096f61c","repo":"AlistGo/alist","slug":"wukong-rename-failed-code-d-message-s","errorCode":null,"errorMessage":"wukong rename failed: code=%d message=%s","messagePattern":"wukong rename failed: code=(.+?) message=(.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/wukong/driver.go","lineNumber":271,"sourceCode":"\tvar resp rawResp\n\t_, err := d.client.R().\n\t\tSetContext(ctx).\n\t\tSetQueryParams(map[string]string{\n\t\t\t\"aid\":             d.Aid,\n\t\t\t\"device_platform\": \"web\",\n\t\t\t\"language\":        d.Language,\n\t\t}).\n\t\tSetBody(map[string]any{\n\t\t\t\"file_id\":  asIDValue(srcID),\n\t\t\t\"new_name\": newName,\n\t\t}).\n\t\tSetResult(&resp).\n\t\tPost(\"/netdisk/user_file/rename_file\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tif resp.Code != 0 {\n\t\treturn fmt.Errorf(\"wukong rename failed: code=%d message=%s\", resp.Code, resp.Message)\n\t}\n\treturn nil\n}\n\nfunc (d *Wukong) Remove(ctx context.Context, obj model.Obj) error {\n\tfileID := obj.GetID()\n\tif fileID == \"\" {\n\t\treturn errors.New(\"missing file id\")\n\t}\n\n\tvar resp rawResp\n\t_, err := d.client.R().\n\t\tSetContext(ctx).\n\t\tSetQueryParams(map[string]string{\n\t\t\t\"aid\":             d.Aid,\n\t\t\t\"device_platform\": \"web\",\n\t\t\t\"language\":        d.Language,\n\t\t}).","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/wukong/driver.go#L253-L289","documentation":"Thrown by the Wukong driver's Rename after POSTing file_id and new_name to /netdisk/user_file/rename_file. The API responded HTTP-level OK but with a non-zero business code, rejecting the rename. Common upstream reasons: the new name is invalid (illegal characters, too long, empty), a same-named entry exists in the folder, or the file_id is unknown.","triggerScenarios":"Renaming to a name that already exists among siblings; newName containing / : * ? \\\" < > or other forbidden characters; renaming a remotely-deleted file whose ID is stale; expired session.","commonSituations":"Frontend rename dialog passing an unsanitized name; concurrent renames creating name collisions; listings cached across a remote deletion; quota/permission limits on shared folders.","solutions":["List the parent folder and confirm no sibling already uses newName; if it does, ask the user or auto-suffix","Validate newName against forbidden characters, control chars, empty string, and length limits before the call","Refresh the object listing so srcObj.GetID() is current, then retry","Re-login if resp.Message indicates an authorization code"],"exampleFix":"// before\nif err := d.Rename(ctx, srcObj, newName); err != nil { return err }\n\n// after\nif strings.ContainsAny(newName, \"\\/:*?\\\"<>|\") || strings.TrimSpace(newName) == \"\" {\n    return fmt.Errorf(\"invalid file name: %q\", newName)\n}\nif err := d.Rename(ctx, srcObj, newName); err != nil { return err }","handlingStrategy":"validation","validationCode":"func validWukongName(name string) bool {\n    return name != \"\" && !strings.ContainsAny(name, \"\\/:*?\\\"<>|\") && len(name) <= 255\n}\nif !validWukongName(newName) {\n    return fmt.Errorf(\"invalid new name: %q\", newName)\n}","typeGuard":null,"tryCatchPattern":"if err := d.Rename(ctx, srcObj, newName); err != nil {\n    if strings.Contains(err.Error(), \"exist\") {\n        return fmt.Errorf(\"name %q already taken in target folder\", newName)\n    }\n    return err\n}","preventionTips":["Validate name charset, length, and non-emptiness client-side","Check siblings for the target name before renaming","Treat 'already exists' codes distinctly so the UI can suggest an alternate name"],"tags":["wukong","rename","api-error","validation","cloud-storage","go"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}