AtlassianPS / JiraPS

PowerShell module to interact with Atlassian JIRA
https://AtlassianPS.org/module/JiraPS
MIT License
322 stars 131 forks source link

Null username error when submitting New-JiraIssue #403

Closed quadrilo44 closed 4 years ago

quadrilo44 commented 4 years ago

Description

From today, when creating a new issue, I am getting the following errors:

Get-JiraUser : Cannot bind argument to parameter 'UserName' because it is null.
At \\USERPATH\Documents\WindowsPowerShell\Modules\JiraPS\2.12.5\JiraPS.psm1:2773 char:40
+                 Get-JiraUser -UserName $result.Name -Exact
+                                        ~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-JiraUser], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Get-JiraUser

Invoke-JiraMethod :
reporter
--------
Reporter is required.
At \\USERPATH\Documents\WindowsPowerShell\Modules\JiraPS\2.12.5\JiraPS.psm1:3842 char:27
+             if ($result = Invoke-JiraMethod @parameter) {
+                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidResult: (:) [Invoke-JiraMethod], RuntimeException
    + FullyQualifiedErrorId : InvalidResponse.Status400,Invoke-JiraMethod

Steps To Reproduce

Add new issue using the New-JiraIssue command.

Expected behavior

Issue should be created successfully

Your Environment

Get-Module JiraPS -ListAvailable | Select Name, Version
Name   Version
----   -------
JiraPS 2.12.5

$PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.16299.1146
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.16299.1146
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Possible Solution

Looks like the "Name" attribute used in "Get-JiraUser -UserName $result.Name -Exact" is no longer returned.

LaurentGoderre commented 4 years ago

This seems to be caused by the fact that the Name column in the Get-JiraUser function is empty. It's trying to set the reporter to the current user but fails because the name is not found.

jeffadavidson commented 4 years ago

I agree with @LaurentGoderre. The New-JiraIssue is attempting to get a reporter using Get-JiraUser and returning null instead.

A possible work around is to provide a reporter directly in the parameters you provide. EG

New-JiraIssue -Project "SomeProject" -IssueType "Bug" -Summary "Test Reporter Issue" -Reporter "Anonymous"

OR 

$Parameters = @{
  Project = "SomeProject"
  IssueType = "Bug"
  Summary = "Test Reporter Issue"
  Reporter = "Anonymous"
}

New-JiraIssue @Parameters
jeffadavidson commented 4 years ago

So I was looking into this a bit more. It looks like the root cause might be JIRA removing username(s) from their endpoints due to GDPR. Account IDs have replaced them it seems

quadrilo44 commented 4 years ago

They remove name for privacy reasons but keep emailAddress and displayName? Weird.

I suspect this is also the cause of the other couple of recent issues to do with Reporter and Assignee failing.

lipkau commented 4 years ago

Thank you for reporting this. This behavior has the same cause as #404 . I am closing this as a duplicate. please follow that ticket for keeping up-to-date

LaurentGoderre commented 4 years ago

407