AlistGo/alist · info

failed to marshal rename request: %w

Error message

failed to marshal rename request: %w

What it means

Returned when json.Marshal of the RenameRequest struct fails. RenameRequest is a plain struct of string fields (Name, NameSignatureEmail, Hash, OriginalHash), so marshalling is statically known to succeed; this error is effectively unreachable defensive code.

Source

Thrown at drivers/proton_drive/util.go:634

		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)
	}

	httpReq, err := http.NewRequestWithContext(ctx, "PUT", renameURL, bytes.NewReader(reqBody))
	if err != nil {
		return fmt.Errorf("failed to create HTTP request: %w", err)
	}

	httpReq.Header.Set("Content-Type", "application/json")
	httpReq.Header.Set("Accept", d.protonJson)
	httpReq.Header.Set("X-Pm-Appversion", d.webDriveAV)
	httpReq.Header.Set("X-Pm-Drive-Sdk-Version", d.sdkVersion)
	httpReq.Header.Set("X-Pm-Uid", d.credentials.UID)
	httpReq.Header.Set("Authorization", "Bearer "+d.credentials.AccessToken)

	client := &http.Client{}
	resp, err := client.Do(httpReq)
	if err != nil {
		return fmt.Errorf("failed to execute rename request: %w", err)

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Confirm the error is really from this line and not a wrapped child error
  2. If a custom RenameRequest adds complex fields, implement json.Marshaler on it or pre-encode to a string
Defensive patterns

Strategy: try-catch

Try / catch

if err := d.Rename(ctx, src, newName); err != nil && strings.Contains(err.Error(), "marshal rename request") {
    log.Error("unexpected marshal failure — RenameRequest schema drifted")
}

Prevention

When it happens

Trigger: Only if RenameRequest were changed to contain a channel, func, or cyclic reference — none exist in the current type.

Common situations: Virtually none; if it ever fires, suspect a fork of the driver that added an unmarshalable field (e.g. an io.Reader or map with non-string keys) to RenameRequest.

Related errors


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