Skip to content

Bug report: spo file move throws unclear error when specifying --deleteIfAlreadyExist #4703

Closed
@milanholemans

Description

@milanholemans

Description

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

image

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions