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

Unhandled error in Get-VenafiTeam #126

Closed
Saadi6 opened this issue Jul 2, 2022 · 0 comments · Fixed by #130
Closed

Unhandled error in Get-VenafiTeam #126

Saadi6 opened this issue Jul 2, 2022 · 0 comments · Fixed by #130
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@Saadi6
Copy link
Collaborator

Saadi6 commented Jul 2, 2022

Environment

Operating System: N/A
VenafiPS version: 4.4.0
PowerShell version: All
TPP version (if applicable): All

Steps to reproduce

Pass ID for an AD based user or group into Get-VenafiTeam.

Expected behavior

The function should check passed ID belongs to a local Team before execution OR handle the resulting error internally.

Actual behavior

Function throws an error:

Get-VenafiTeam -ID 'AD+BigSur:594a960d633cfc40af1f1cf8d4241c37'         
InvalidArgument: /Users/saad.humayun/Downloads/VenafiPS/VenafiPS/Public/Get-VenafiTeam.ps1:114
Line |
 114 |                      $guid = [guid]($ID.Replace('local:', ''))
     |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot convert value "AD+BigSur:594a960d633cfc40af1f1cf8d4241c37" to type "System.Guid". Error: "Guid should
     | contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)."

InvalidOperation: /Users/saad.humayun/Downloads/VenafiPS/VenafiPS/Public/Get-VenafiTeam.ps1:125
Line |
 125 |  …             $params.UriLeaf = ('Teams/local/{{{0}}}' -f $guid.ToStrin …
     |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | You cannot call a method on a null-valued expression.


cmdlet Invoke-VenafiRestMethod at command pipeline position 1
Supply values for the following parameters:
UriLeaf: 

More Info

The example provided uses AD group to deliberately cause the error. However, it can easily occur when calling
Find-TppIdentity -Name 'Unix' | Get-VenafiTeam
if there is an AD group or User having name beginning with Unix.

Since all AD/LDAP based identities begin with AD or LDAP, you can use a regex to exclude them in the function. This should be a lot quicker than resolving the ID to check if it is indeed a team.

@gdbarron gdbarron added bug Something isn't working good first issue Good for newcomers labels Jul 2, 2022
@gdbarron gdbarron self-assigned this Jul 11, 2022
gdbarron added a commit that referenced this issue Jul 11, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants