[GH-ISSUE #47] Invoke-PveRestApi does not catch empty PveTicketLast #30

Closed
opened 2026-02-26 17:32:13 +03:00 by kerem · 0 comments
Owner

Originally created by @r3st0r3 on GitHub (Dec 19, 2025).
Original GitHub issue: https://github.com/Corsinvest/cv4pve-api-powershell/issues/47

What happened?

If no cluster connect happens before first call of Invoke-PveRestApi an error is thrown:

$session.cookies.add($cookie) >> Exception calling "Add" with "1" argument(s): "The parameter 'cookie.Domain' cannot be an empty string. (Parameter 'cookie')"

Instead the function should throw an exception when the fallback to $Global:PveTicketLast does not work because it is empty/null.

To reproduce use following code for example (load module before):
Get-PveClusterOptions

Error

MethodInvocationException: C:\xxxxxxxxxxxxxx
Line |
256 | $session.cookies.add($cookie)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Exception calling "Add" with "1" argument(s): "The parameter 'cookie.Domain' cannot be an empty string.
| (Parameter 'cookie')"

Response :
StatusCode : -1
ReasonPhrase : Cannot bind parameter 'Uri'. Cannot convert value "https://:/api2/json/cluster/options" to type
"System.Uri". Error: "Invalid URI: The hostname could not be parsed."
IsSuccessStatusCode : False
RequestResource : /cluster/options
Parameters : {}
Method : Get
ResponseType : json

Yes this only happens when the coder/user forgets to connect first or when the connect attempt fails and is not catched. But clean code should throw an exception here.

Expected behavior

clean and catchable exception like:

Exception: Cxxxxxxxxxxxxxxxx
Line |
234 | throw 'No PveTicket - Cluster Connect missing?'
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| No PveTicket - Cluster Connect missing?

Relevant log output


Proxmox VE Version

9.1.0

Module Version

9.1.0

PowerShell Version

7.4.10

Version (working)

No response

On what operating system are you experiencing the issue?

Windows

Pull Request

  • I would like to do a Pull Request
Originally created by @r3st0r3 on GitHub (Dec 19, 2025). Original GitHub issue: https://github.com/Corsinvest/cv4pve-api-powershell/issues/47 ### What happened? If no cluster connect happens before first call of Invoke-PveRestApi an error is thrown: > $session.cookies.add($cookie) >> Exception calling "Add" with "1" argument(s): "The parameter 'cookie.Domain' cannot be an empty string. (Parameter 'cookie')" Instead the function should throw an exception when the fallback to $Global:PveTicketLast does not work because it is empty/null. To reproduce use following code for example (load module before): `Get-PveClusterOptions` Error > MethodInvocationException: C:\xxxxxxxxxxxxxx > Line | > 256 | $session.cookies.add($cookie) > | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > | Exception calling "Add" with "1" argument(s): "The parameter 'cookie.Domain' cannot be an empty string. > | (Parameter 'cookie')" > > Response : > StatusCode : -1 > ReasonPhrase : Cannot bind parameter 'Uri'. Cannot convert value "https://:/api2/json/cluster/options" to type > "System.Uri". Error: "Invalid URI: The hostname could not be parsed." > IsSuccessStatusCode : False > RequestResource : /cluster/options > Parameters : {} > Method : Get > ResponseType : json Yes this only happens when the coder/user forgets to connect first or when the connect attempt fails and is not catched. But clean code should throw an exception here. ### Expected behavior clean and catchable exception like: > Exception: Cxxxxxxxxxxxxxxxx > Line | > 234 | throw 'No PveTicket - Cluster Connect missing?' > | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > | No PveTicket - Cluster Connect missing? ### Relevant log output ```shell ``` ### Proxmox VE Version 9.1.0 ### Module Version 9.1.0 ### PowerShell Version 7.4.10 ### Version (working) _No response_ ### On what operating system are you experiencing the issue? Windows ### Pull Request - [x] I would like to do a Pull Request
kerem closed this issue 2026-02-26 17:32:13 +03:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/cv4pve-api-powershell#30
No description provided.