Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug report: "planner task get" cannot handle taskId starting with a dash #4256

Closed
dojcsakj opened this issue Dec 19, 2022 · 8 comments
Closed

Comments

@dojcsakj
Copy link
Contributor

Description

When a taskId starts with a dash (-) the "planner task get" command returns

"Error: 'true' is not a valid output type. Allowed output types are csv, json, text"

instead of the task

Steps to reproduce

m365 planner task get -i "-9rMKQooUjZdxgv1qQVZYABEuw"

Expected results

The task data in json format

Actual results

Error: 'true' is not a valid output type. Allowed output types are csv, json, text

Diagnostics

Error: 'true' is not a valid output type. Allowed output types are csv, json, text

CLI for Microsoft 365 version

v6.0.0

nodejs version

v14.17.1

Operating system (environment)

Linux

Shell

bash

cli doctor

{
"os": {
"platform": "linux",
"version": "#27-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 23 20:44:15 UTC 2022",
"release": "5.19.0-26-generic"
},
"cliVersion": "6.0.0",
"nodeVersion": "v14.17.1",
"cliAadAppId": "31359c7f-bd7e-475c-86db-fdb8c937548e",
"cliAadAppTenant": "common",
"authMode": "DeviceCode",
"cliEnvironment": "",
"cliConfig": {},
"roles": [],
"scopes": [
"AllSites.FullControl",
"AppCatalog.ReadWrite.All",
"ChannelMember.ReadWrite.All",
"ChannelMessage.Read.All",
"ChannelMessage.Send",
"ChannelSettings.ReadWrite.All",
"Chat.Read",
"Chat.ReadWrite",
"Directory.AccessAsUser.All",
"Directory.ReadWrite.All",
"Group.ReadWrite.All",
"IdentityProvider.ReadWrite.All",
"Mail.ReadWrite",
"Mail.Send",
"Place.Read.All",
"Policy.Read.All",
"Reports.Read.All",
"ServiceHealth.Read.All",
"ServiceMessage.Read.All",
"ServiceMessageViewpoint.Write",
"Tasks.ReadWrite",
"Team.Create",
"TeamMember.ReadWrite.All",
"TeamsApp.ReadWrite.All",
"TeamsAppInstallation.ReadWriteForUser",
"TeamSettings.ReadWrite.All",
"TeamsTab.ReadWrite.All",
"TermStore.ReadWrite.All",
"User.Invite.All",
"User.ReadWrite.All",
"profile",
"openid",
"email",
"AllSites.FullControl",
"AppCatalog.ReadWrite.All",
"ChannelMember.ReadWrite.All",
"ChannelMessage.Read.All",
"ChannelMessage.Send",
"ChannelSettings.ReadWrite.All",
"Chat.Read",
"Chat.ReadWrite",
"Directory.AccessAsUser.All",
"Directory.ReadWrite.All",
"Group.ReadWrite.All",
"IdentityProvider.ReadWrite.All",
"Mail.ReadWrite",
"Mail.Send",
"Place.Read.All",
"Policy.Read.All",
"Reports.Read.All",
"ServiceHealth.Read.All",
"ServiceMessage.Read.All",
"ServiceMessageViewpoint.Write",
"Tasks.ReadWrite",
"Team.Create",
"TeamMember.ReadWrite.All",
"TeamsApp.ReadWrite.All",
"TeamsAppInstallation.ReadWriteForUser",
"TeamSettings.ReadWrite.All",
"TeamsTab.ReadWrite.All",
"TermStore.ReadWrite.All",
"User.Invite.All",
"User.ReadWrite.All",
"AllSites.FullControl",
"AppCatalog.ReadWrite.All",
"ChannelMember.ReadWrite.All",
"ChannelMessage.Read.All",
"ChannelMessage.Send",
"ChannelSettings.ReadWrite.All",
"Chat.Read",
"Chat.ReadWrite",
"Directory.AccessAsUser.All",
"Directory.ReadWrite.All",
"Group.ReadWrite.All",
"IdentityProvider.ReadWrite.All",
"Mail.ReadWrite",
"Mail.Send",
"Place.Read.All",
"Policy.Read.All",
"Reports.Read.All",
"ServiceHealth.Read.All",
"ServiceMessage.Read.All",
"ServiceMessageViewpoint.Write",
"Tasks.ReadWrite",
"Team.Create",
"TeamMember.ReadWrite.All",
"TeamsApp.ReadWrite.All",
"TeamsAppInstallation.ReadWriteForUser",
"TeamSettings.ReadWrite.All",
"TeamsTab.ReadWrite.All",
"TermStore.ReadWrite.All",
"User.Invite.All",
"User.ReadWrite.All",
"user_impersonation",
"AppCatalog.ReadWrite.All",
"ChannelMember.ReadWrite.All",
"ChannelMessage.Read.All",
"ChannelMessage.Send",
"ChannelSettings.ReadWrite.All",
"Chat.Read",
"Chat.ReadWrite",
"Directory.AccessAsUser.All",
"Directory.ReadWrite.All",
"Group.ReadWrite.All",
"IdentityProvider.ReadWrite.All",
"Mail.ReadWrite",
"Mail.Send",
"Place.Read.All",
"Policy.Read.All",
"Reports.Read.All",
"ServiceHealth.Read.All",
"ServiceMessage.Read.All",
"ServiceMessageViewpoint.Write",
"Tasks.ReadWrite",
"Team.Create",
"TeamMember.ReadWrite.All",
"TeamsApp.ReadWrite.All",
"TeamsAppInstallation.ReadWriteForUser",
"TeamSettings.ReadWrite.All",
"TeamsTab.ReadWrite.All",
"User.Invite.All",
"AppCatalog.ReadWrite.All",
"ChannelMember.ReadWrite.All",
"ChannelMessage.Read.All",
"ChannelMessage.Send",
"ChannelSettings.ReadWrite.All",
"Chat.Read",
"Chat.ReadWrite",
"Directory.AccessAsUser.All",
"Directory.ReadWrite.All",
"Group.ReadWrite.All",
"IdentityProvider.ReadWrite.All",
"Mail.ReadWrite",
"Mail.Send",
"Place.Read.All",
"Policy.Read.All",
"Reports.Read.All",
"ServiceHealth.Read.All",
"ServiceMessage.Read.All",
"ServiceMessageViewpoint.Write",
"Tasks.ReadWrite",
"Team.Create",
"TeamMember.ReadWrite.All",
"TeamsApp.ReadWrite.All",
"TeamsAppInstallation.ReadWriteForUser",
"TeamSettings.ReadWrite.All",
"TeamsTab.ReadWrite.All",
"User.Invite.All"
]
}

Additional Info

No response

@milanholemans
Copy link
Contributor

Hi @dojcsakj

Thank you for logging this issue. We'll have a look at it!

@milanholemans
Copy link
Contributor

milanholemans commented Dec 19, 2022

Ok just checked some things out.
Seems like the issue is minimist on this line:

// parse args to see if a command has been specified and can be loaded
// rather than loading all commands
const parsedArgs: minimist.ParsedArgs = minimist(rawArgs);

When running your command (m365 planner task get -i "-9rMKQooUjZdxgv1qQVZYABEuw"), minimist is parsing the arguments. It thinks that -i is a flag and that 9rMKQooUjZdxgv1qQVZYABEuw are all flags as well. So it parses the arguments to:

{
  "1": true,
  "9": true,
  "_": [
    "planner",
    "task",
    "get"
  ],
  "i": true,
  "r": true,
  "M": true,
  "K": true,
  "Q": true,
  "o": true,
  "U": true,
  "j": true,
  "Z": true,
  "d": true,
  "x": true,
  "g": true,
  "v": true,
  "q": true,
  "V": true,
  "Y": true,
  "A": true,
  "B": true,
  "E": true,
  "u": true,
  "w": true
}

And because -o is the short for output and true is not a valid output, you are getting the error message: Error: 'true' is not a valid output type. Allowed output types are csv, json, text.
Since it's a minimist problem, all commands are suffering from this issue as well.

Any ideas how to fix this @pnp/cli-for-microsoft-365-maintainers?

@milanholemans
Copy link
Contributor

Seems like there is sort of similar issue open already in the minimist GitHub repo: minimistjs/minimist#15

@milanholemans
Copy link
Contributor

Hi @dojcsakj

As expected, because your ID is starting with a dash, we are parsing everything behind it as an option. You can avoid this by using an embedded option value with an = like m365 planner task get -i="-9rMKQooUjZdxgv1qQVZYABEuw".

Can you confirm that this works for you?

@martinlingstuyl
Copy link
Contributor

Great research @milanholemans! Ah, the many intricacies of using minimist 😂

I'd think it would be helpful to have this in the 'using the CLI' docs, what about you?

@dojcsakj
Copy link
Contributor Author

Yes, it works! :) Thank you.

@milanholemans
Copy link
Contributor

I'd think it would be helpful to have this in the 'using the CLI' docs, what about you?

I was thinking the same 😃

@milanholemans
Copy link
Contributor

Since the issue has been resolved, I'll close the issue and create a new one to add this to our "using the CLI" docs.
Once again thank you for this great feedback @dojcsakj!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants