pnp / pnp/cli-microsoft365

Bug report: Version history/metadata not preserved when copying files using SPO file copy command

Open
#6,712 11 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug keep-open
Dominant language
TypeScript
Stars
1.5k
Forks
413
Avg merge
5d 6h
Merged PRs (30d)
21

Description

Priority

(Urgent) I can't use the CLI

Description

When using the m365 spo file copy command to copy files between SharePoint locations, the version history and associated metadata of the file are not preserved in the destination location.

Steps to reproduce
  1. Have a source file with version history in SharePoint Online
    Image

  2. Run the following command:m365 spo file copy --webUrl https://contoso.sharepoint.com/sites/project --sourceUrl /sites/project/Customer2/Product-Catalog.pdf --targetUrl /sites/project/Customer1

  3. Check the copied file in the target location

Image

Expected results

The file should be copied with its complete version history and metadata preserved.

Actual results

The file is copied successfully, but while the version number (e.g., "8.0") is preserved, the version history details and associated metadata from the source file are lost. The version information in the target shows the correct version number, but the history of changes and previous versions are not accessible.

I also tried using the parameter --ignoreVersionHistory false but it did not improve the situation. The detailed version history was still not preserved.

Both source and target document libraries have identical metadata fields, and there are no required fields that would prevent successful metadata migration.

Diagnostics

{
"CheckInComment": "",
"CheckOutType": 2,
"ContentTag": "{308A6B11-5245-423E-9273-98529969046A},9,1",
"CustomizedPageStatus": 0,
"ETag": ""{308A6B11-5245-423E-9273-98529969046A},9"",
"Exists": true,
"ExistsAllowThrowForPolicyFailures": true,
"ExistsWithException": true,
"IrmEnabled": false,
"Length": "1285533",
"Level": 1,
"LinkingUri": null,
"LinkingUrl": "",
"MajorVersion": 8,
"MinorVersion": 0,
"Name": "Product-Catalog.pdf",
"ServerRelativeUrl": "/sites/project/Customer1/Product-Catalog.pdf",
"TimeCreated": "2025-05-05T12:02:55Z",
"TimeLastModified": "2025-05-05T12:02:55Z",
"Title": "Product Catalog Modified Ver 3",
"UIVersion": 4096,
"UIVersionLabel": "8.0",
"UniqueId": "308a6b11-5245-423e-9273-98529969046a"
}

CLI for Microsoft 365 version

v10.5.0

nodejs version

v20.11.1

Operating system (environment)

Windows

Shell

PowerShell

cli doctor

No response

Additional Info

This is important functionality for migration scenarios where preserving the complete history of document changes is required.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the m365 spo file copy command implementation and trace how it handles --ignoreVersionHistory false when copying between SharePoint locations. Reproduce the issue with a source file containing version history and matching metadata fields. Done means the destination exposes the source file's complete version history and associated metadata, not only its current version number.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.