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

DELETE request crashes when passing optional parameters #50

Open
zeroSal opened this issue Sep 7, 2023 · 3 comments
Open

DELETE request crashes when passing optional parameters #50

zeroSal opened this issue Sep 7, 2023 · 3 comments

Comments

@zeroSal
Copy link

zeroSal commented Sep 7, 2023

I perform a DELETE request using the library (version 4.1.0 installed via composer) in order to delete an existing virtual machine on my proxmox environment.

This is the request I am trying to perform (the screenshot is from my proxmox VM API documentation):
image

When I try to pass optional parameters in the associative array to the request, cURL crashes.
If no optional parameters are passed to the function (I tried to pass an empty array), the function succeeds.
The API URI inside the sprintf() function is correctly built. When the script runs its value is '/nodes/proxmox4/qemu/883', so the issue is not here.

This is the PHP 7.4 code I written:

$this->logger->info('Deleting the virtual machine and its related disks...');
        
$this->proxmox->delete(sprintf('/nodes/%s/qemu/%d', $deleteVm['node'], $deleteVm['vmid']), [
            'destroy-unreferenced-disks' => 1,
            'purge' => 1,
        ]);

This is the RuntimeException caught by the parent class, displayed as warning in the console:
image

@plambert684
Copy link

I have the same problem.
Anyone has found an solution?

@zeroSal
Copy link
Author

zeroSal commented Feb 5, 2024

@plambert684

No answers from @zzantares so far, this is still my piece of code in the project ;(

$this->logger->info('Deleting the virtual machine and its related disks...');
$this->proxmox->delete(sprintf('/nodes/%s/qemu/%d', $deleteVm['node'], $deleteVm['vmid']), [/*
     FIXME: This parameters crashes the request, leave uneffective for now. An issue to the maintaner has been opened.
    'destroy-unreferenced-disks' => 1,
    'purge' => 1,
*/]);
`

@zzantares
Copy link
Owner

zzantares commented Mar 5, 2024

Apologies for the late response. The DELETE request is constructed here: https://github.com/zzantares/ProxmoxVE/blob/master/src/Proxmox.php#L126-L136 I'll suggest adding a test case below/similar to this one https://github.com/zzantares/ProxmoxVE/blob/master/tests/ProxmoxTest.php#L226-L230 that stresses this corner case that help debug and fix the issue.

Sadly I no longer have the resources to continue maintaining this library, but if someone submits a patch I'll help to review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants