AlistGo/alist · error

rename API call failed: %w

Error message

rename API call failed: %w

What it means

Umbrella error for any failure of executeRenameAPI during Rename. It wraps one of: HTTP request construction, transport failure, non-200 status, response decode failure, or a Proton API code other than 1000. Inspect the wrapped error (%w chain) to tell which stage failed.

Source

Thrown at drivers/proton_drive/util.go:616

	if err != nil {
		return nil, fmt.Errorf("failed to generate new hash: %w", err)
	}

	originalHash, err := d.getOriginalNameHash(srcLink)
	if err != nil {
		return nil, fmt.Errorf("failed to get original hash: %w", err)
	}

	renameReq := RenameRequest{
		Name:               encryptedName,
		NameSignatureEmail: d.MainShare.Creator,
		Hash:               newHash,
		OriginalHash:       originalHash,
	}

	err = d.executeRenameAPI(ctx, srcLink.LinkID, renameReq)
	if err != nil {
		return nil, fmt.Errorf("rename API call failed: %w", err)
	}

	return &model.Object{
		Name:     newName,
		Size:     srcObj.GetSize(),
		Modified: srcObj.ModTime(),
		IsFolder: srcObj.IsDir(),
	}, nil
}

func (d *ProtonDrive) executeRenameAPI(ctx context.Context, linkID string, req RenameRequest) error {

	renameURL := fmt.Sprintf(d.apiBase+"/drive/v2/volumes/%s/links/%s/rename",
		d.MainShare.VolumeID, linkID)

	reqBody, err := json.Marshal(req)
	if err != nil {
		return fmt.Errorf("failed to marshal rename request: %w", err)

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Check errors.Unwrap chain / response status: 401 -> refresh credentials via the authenticated proton client before retrying
  2. 429 -> back off and retry with the Retry-After header
  3. If code != 1000 indicates hash mismatch, re-fetch the link and recompute hashes (see errors 980/987)
  4. Route renames through the official proton-go client instead of the raw HTTP path so token refresh and error codes are handled
Defensive patterns

Strategy: retry

Try / catch

err := d.Rename(ctx, src, newName)
for attempts := 0; isRetryableRenameErr(err) && attempts < 2; attempts++ {
    time.Sleep(backoff(attempts))
    err = d.Rename(ctx, src, newName)
}
func isRetryableRenameErr(err error) bool {
    return errors.Is(err, context.DeadlineExceeded) ||
        strings.Contains(err.Error(), "status 429") ||
        strings.Contains(err.Error(), "status 401") // after token refresh
}

Prevention

When it happens

Trigger: PUT {apiBase}/drive/v2/volumes/{VolumeID}/links/{LinkID}/rename returning 401 (expired access token, since this raw http.Client path never refreshes tokens), 429 rate limit, 403, or body code != 1000 (hash mismatch, duplicate name).

Common situations: Long-lived mounts whose Proton access token expired (no refresh on this code path); aggressive scripted renames hitting rate limits; renamed-while-offline clients with stale OriginalHash; wrong appversion/sdk headers after a Proton API change.

Related errors


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