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

Cannot assign issue to a user using Set-JiraIssue #320

Open
michalporeba opened this issue Nov 30, 2018 · 14 comments
Open

Cannot assign issue to a user using Set-JiraIssue #320

michalporeba opened this issue Nov 30, 2018 · 14 comments

Comments

@michalporeba
Copy link

Description

Assigning JIRA issues to a user with Set-JiraIssue suddenly stopped working.

Steps To Reproduce

  1. start a new session with New-JiraSession
  2. Execute
 (Get-JiraIssue Issue-123) | Set-JiraIssue -Assignee (Get-JiraUser)
  1. The error is
Invoke-JiraMethod : Can not deserialize instance of java.lang.String out of START_ARRAY token
 at [Source: org.apache.catalina.connector.CoyoteInputStream@184681e6; line: 2, column: 5] (through reference chain: com.atlassian.jira.rest.v2.issue.UserBean["name"])
At C:\Program Files\WindowsPowerShell\Modules\jiraps\2.8.6\Public\Set-JiraIssue.ps1:206 char:21
+                     Invoke-JiraMethod @parameter
+                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidResult: (:) [Invoke-JiraMethod], RuntimeException
    + FullyQualifiedErrorId : InvalidResponse.Status400,Invoke-JiraMethod

Expected behavior

Up to recently this was assigning the issue to the signed user.
Changing (Get-JiraUser) to a username string doesn't solve it.

Your Environment

JiraPS 2.8.6
PSVersion 5.1.16299.785

@alexsuslin
Copy link
Contributor

Get-JiraUser having validation attribute [ValidateNotNullOrEmpty()]
Weird but there is no any error when running this command without parameters

@lipkau
Copy link
Member

lipkau commented Dec 5, 2018

  1. Running the command without parameters should return the information about the user that is logged on. As defined in the docs.

  2. The output of Get-JiraUser is currently not suitable for Set-JiraIssue. This was already reported in The output of Get-JiraUser should be suitable as input for Set-JiraIssue #200 .
    You can add a (Get-JiraUser).Name to work around it for now

@michalporeba
Copy link
Author

michalporeba commented Dec 7, 2018

I don't think this is a duplicat @lipkau. I have included (Get-JiraUser) in the example so I don't have to show my username, but it fails with the same exception regardless if you use -Assignee (Get-JiraUser), -Assignee (Get-JiraUser).Name or if you simply pass a string representing the user like so -Assignee myusername. So my problem, and this issue #320 is not about the Get-JiraUser but rather the Set-JiraIssue command.

@lipkau
Copy link
Member

lipkau commented Dec 8, 2018

I am unable to replicate the behavior you described:

image

@lipkau
Copy link
Member

lipkau commented Dec 21, 2018

Please show how you are running these commands and the output of them.

@derekbartram
Copy link

derekbartram commented Jan 7, 2019

I too get this problem; if I run the commands as you have lipkau, I get

Invoke-JiraMethod : Can not deserialize instance of java.lang.String out of START_ARRAY token
 at [Source: org.apache.catalina.connector.CoyoteInputStream@2dd22d10; line: 2, column: 5] (through reference chain: com.atlassian.jira.rest.v2.issue.UserBean["name"])
At C:\Program Files\WindowsPowerShell\Modules\JiraPS\2.9.0\JiraPS.psm1:5335 char:21
+                     Invoke-JiraMethod @parameter
+                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidResult: (:) [Invoke-JiraMethod], RuntimeException
    + FullyQualifiedErrorId : InvalidResponse.Status400,Invoke-JiraMethod`

@lipkau
Copy link
Member

lipkau commented Jan 7, 2019

Please show me the payload of $Body and $splatParameters | Out-String when you run the command with -debug when you see this message:

Write-Debug "[$($MyInvocation.MyCommand.Name)] Invoke-WebRequest with `$splatParameters: $($splatParameters | Out-String)"

@michalporeba
Copy link
Author

image
image
@lipkau is that what you need?

@lipkau
Copy link
Member

lipkau commented Jan 8, 2019

Almost.
on the last message of the first screenshot, enter s and hit enter
then you can see the content of the local variables. such as $Body

@michalporeba
Copy link
Author

michalporeba commented Jan 8, 2019 via email

@michalporeba
Copy link
Author

I have noticed two more things this morning when running the command with the -Debug option.
First of all it fails only for some of the users, specifically so far I have only noticed that it fails only for my user, for other users I tried it works.

During execution of the Set-JiraIssue a call is made to rest/api/latest/user/search? and then 3 different calls to rest/api/2/user passing 3 different user names: mine and two other usernames that start with exact my username + and extra character at the end.

So I tried Get-JiraUser -UserName <myusername> and I got the same behaviour - 3 users not 1.

@lipkau
Copy link
Member

lipkau commented Jan 9, 2019

This behavior is know (#49) and already planned to changed (#306).
But as it's a breaking change, it will only be released with v3.0.

for now you will have to manage with something like

Get-JiraUser -UserName <myusername> | Where name -eq <myusername>

@michalporeba
Copy link
Author

Please have a look at this merge request. It fixes the issue without breaking changes.

@michalporeba
Copy link
Author

I have a unit test to cover the -Exact option and modified one to be more explicit how the Get-JiraUser should work when the -Exact is not used. I have also updated the Get-JiraUser documentations.

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

4 participants