Skip to content

New command: spo folder unarchive. Closes #7182 - #7405

Open
Saurabh7019 wants to merge 3 commits into
pnp:mainfrom
Saurabh7019:issue-7182
Open

Saurabh7019 wants to merge 3 commits into
pnp:mainfrom
Saurabh7019:issue-7182

Conversation

@Saurabh7019

Copy link
Copy Markdown
Contributor

Closes #7182

@Saurabh7019
Saurabh7019 marked this pull request as ready for review June 17, 2026 18:33
@milanholemans
milanholemans requested a balanced review from Copilot September 5, 2026 22:01
@milanholemans milanholemans self-assigned this Sep 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The prompt-confirmed execution path lacks coverage, preventing the required 100% branch coverage.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds the spo folder unarchive command for reactivating SharePoint folders by URL or ID.

Changes:

  • Implements validation, confirmation, and SharePoint REST calls.
  • Adds unit tests and documentation.
  • Registers the command and sidebar entry.
File summaries
File Description
folder-unarchive.ts Implements the command.
folder-unarchive.spec.ts Tests validation and execution.
commands.ts Registers the command name.
sidebars.ts Adds documentation navigation.
folder-unarchive.mdx Documents usage and permissions.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/m365/spo/commands/folder/folder-unarchive.spec.ts

@milanholemans milanholemans left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks almost good to go. Noticed a few things we should take a look at before shipping this.

Comment thread docs/src/config/sidebars.ts Outdated
Comment thread src/m365/spo/commands/folder/folder-unarchive.spec.ts
let loggerLogSpy: sinon.SinonSpy;

const unarchiveResponse = {
value: '{"IsArchive":false,"TotalFileCount":2,"CreatedUtcDateTime":"2026-06-17T12:32:15.3479567Z","LastStartedUtcDateTime":"0001-01-01T00:00:00","FolderArchiveStatus":"Unknown","ProcessedFileCount":0,"SuccessCount":0,"FailureCount":0,"NotArchivableFileCount":0,"ProgressPercentage":0.0}'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this response really a JSON string instead of just a JSON object?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, the response is a JSON string, not an object.

Comment on lines +88 to +90
if (!folderInfo.Exists) {
throw `The folder '${url || id}' does not exist.`;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this Exists parameter have any use? If a folder doesn't exist you just receive a 404, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it is needed. both GetFolderByServerRelativePath and GetFolderById return 200 with {"Exists": false} when a folder doesn't exist.

Response:
{
  "url": "https://contoso.sharepoint.com/sites/M365SOBA/_api/web/GetFolderByServerRelativePath(DecodedUrl='%2Fsites%2FM365SOBA%2FShared%20Documents%2FGeneral%2FStream123')?$select=Exists,ListItemAllFields/Id,ListItemAllFields/ParentList/Id&$expand=ListItemAllFields,ListItemAllFields/ParentList",
  "status": 200,
  "statusText": "OK",
  "headers": {
  },
  "data": {
    "Exists": false
  }
}

Comment thread src/m365/spo/commands/folder/folder-unarchive.spec.ts Outdated
Comment on lines +315 to +325
it('throws an error when the folder does not exist by url', async () => {
sinon.stub(request, 'get').resolves({});

await assert.rejects(command.action(logger, {
options: {
webUrl: 'https://contoso.sharepoint.com/sites/test',
url: '/Shared Documents/temp1',
force: true
}
}), new CommandError(`The folder '/Shared Documents/temp1' does not exist.`));
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it doesn't exist, you get a 404, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it returns 200.

Comment thread src/m365/spo/commands/folder/folder-unarchive.spec.ts
: The server- or site-relative decoded URL of the folder to unarchive. Specify either `url` or `id`, but not both.

`-i, --id [id]`
: The UniqueId (GUID) of the folder to unarchive. Specify either `url` or `id`, but not both.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UniqueId is not really a word.

Suggested change
: The UniqueId (GUID) of the folder to unarchive. Specify either `url` or `id`, but not both.
: The unique ID (GUID) of the folder to unarchive. Specify either `url` or `id`, but not both.

Noticed this word is also used in other unarchive/archive commands. Would be appreciated if you fix it there as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is fixed in archive/unarchive commands.. but the same problem in several other commands

image

should we create a separate issue to track and fix the remaining cases?

@milanholemans
milanholemans marked this pull request as draft September 5, 2026 22:47
Comment thread src/m365/spo/commands/folder/folder-unarchive.ts Outdated
@Saurabh7019
Saurabh7019 marked this pull request as ready for review September 14, 2026 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New command: spo folder unarchive

3 participants