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

Get-VCFTask returns a different $_Exception.Message for VCF 5.1 than whats in the code #277

Open
1 task done
joffer77 opened this issue Mar 4, 2024 · 0 comments
Open
1 task done
Assignees
Labels
bug Bug needs-triage Needs Triage
Milestone

Comments

@joffer77
Copy link

joffer77 commented Mar 4, 2024

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

PowerVCF

2.4.1.1000

VMware Cloud Foundation

5.1.0.0

PowerShell

7.4.1

Guest Operating System

Windows Server 2019

Environment Details

VCF 5.1.0.0 with vCenter 8U2a

Description

Using PowerVCF 2.4.1.1000 I believe running Get-VCFTask on VCF 5.1.0.0 fails due to wrong exception message if the task doesn't exist.

Example output on a task that does not exist:

PS D:\scripts> Get-VCFTask 619cc900-15c5-48c0-840f-0b245bf1f4b3
Script File:       C:\Program Files\PowerShell\Modules\PowerVCF\2.4.1.1000\PowerVCF.psm1 Line: 4339
Relevant Command:  $response = Invoke-RestMethod -Method GET -Uri $uri -Headers $headers
Target Uri:         https://00ab-vcf.sddc.vegvesen.no/v1/tasks/619cc900-15c5-48c0-840f-0b245bf1f4b3
Exception Message: Response status code does not indicate success: 404 ().
Error Message:
{
  "errorCode": "TA_TASK_NOT_FOUND",
  "arguments": [
    "619cc900-15c5-48c0-840f-0b245bf1f4b3"
  ],
  "message": "Task with ID 619cc900-15c5-48c0-840f-0b245bf1f4b3 not found",
  "referenceToken": "8465IV"
}

If I change line 4341 in PowerVCF.psm1 on my server from:
if ($_.Exception.Message -eq "The remote server returned an error: (404) Not Found.") {
to:
if ($_.Exception.Message -eq "Response status code does not indicate success: 404 ().") {
which matches the Exception Message above, then the output looks more correct - output with changed msg:

PS D:\scripts> Get-VCFTask 619cc900-15c5-48c0-840f-0b245bf1f4b3
Get-VCFTask: Task with ID 619cc900-15c5-48c0-840f-0b245bf1f4b3 not found.

Line 4341 in my PowerVCF.psm1 corresponds to line 4411 here on github, not sure why they are different, maybe powershell gallery is to blame.

Expected Behavior

Expected Get-VCFTasks to write a simple error message, not display the full error message/failure

Actual Behavior

Write out full error

Steps to Reproduce

Grab PowerVCF 2.4.1 and run Get-VCFTask on a non-existing ID.

Log Fragments and Files

No response

Screenshots

No response

Additional Context

No response

@joffer77 joffer77 added bug Bug needs-triage Needs Triage labels Mar 4, 2024
@tenthirtyam tenthirtyam self-assigned this Mar 4, 2024
@tenthirtyam tenthirtyam added this to the v2.5.0 milestone Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug needs-triage Needs Triage
Projects
None yet
Development

No branches or pull requests

2 participants