Description
The command spo file move throws an unclear error when you specify --deleteIfAlreadyExist when the destination file does not exist.

This is because we perform an error check when we try to recycle a file that doesn't exist.
|
try { |
|
await Cli.executeCommand(removeCommand as Command, { options: { ...removeOptions, _: [] } }); |
|
} |
|
catch (err: any) { |
|
if (err.error !== undefined && err.error.message !== undefined && err.error.message.includes('does not exist')) { |
|
|
|
} |
|
else { |
|
throw err; |
|
} |
|
} |
However the error returned looks like this:
{"message":"The file /sites/Projectsite/shared documents/Test55/Accountants (Stanley).xlsx does not exist."}
Steps to reproduce
Run m365 spo file move --webUrl <url> --sourceUrl <sourceUrl> --targetUrl <targetUrl> --deleteIfAlreadyExists when the destination file does not exist.
Expected results
Command to run without a problem
Actual results
Error: [object Object]
Diagnostics
No response
CLI for Microsoft 365 version
v6.4.0
nodejs version
v16.18.1
Operating system (environment)
Windows
Shell
PowerShell
cli doctor
No response
Additional Info
No response
Description
The command
spo file movethrows an unclear error when you specify--deleteIfAlreadyExistwhen the destination file does not exist.This is because we perform an error check when we try to recycle a file that doesn't exist.
cli-microsoft365/src/m365/spo/commands/file/file-move.ts
Lines 196 to 206 in 13e2a93
However the error returned looks like this:
{"message":"The file /sites/Projectsite/shared documents/Test55/Accountants (Stanley).xlsx does not exist."}Steps to reproduce
Run
m365 spo file move --webUrl <url> --sourceUrl <sourceUrl> --targetUrl <targetUrl> --deleteIfAlreadyExistswhen the destination file does not exist.Expected results
Command to run without a problem
Actual results
Error: [object Object]
Diagnostics
No response
CLI for Microsoft 365 version
v6.4.0
nodejs version
v16.18.1
Operating system (environment)
Windows
Shell
PowerShell
cli doctor
No response
Additional Info
No response