[GH-ISSUE #36] Expose HTTP Headers for requests made with PveClientBase #27

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

Originally created by @sydive on GitHub (Jul 26, 2024).
Original GitHub issue: https://github.com/Corsinvest/cv4pve-api-php/issues/36

Hey there, thanks for the library, it's been great to use so far.

Overview

This is more of a feature request than bug, but it appears that the Proxmox API returns errors in HTTP headers, rather than the JSON response body in some cases.

This happens in multiple endpoints, but one example can be seen in /api2/json/nodes/{node}/qemu/{vmid}/clone (docs here). Here's what the headers looks like:

HTTP/1.1 500 VM is locked (backup)
Cache-Control: max-age=0
Connection: close
Date: Thu, 25 Jul 2024 23:24:26 GMT
Pragma: no-cache
Server: pve-api-daemon/3.0
Content-Length: 13
Content-Type: application/json;charset=UTF-8
Expires: Thu, 25 Jul 2024 23:24:26 GMT

Since this error is in the header rather than body, it's not present in the following methods for the Result class:

  • getReasonPhrase()
  • getResponse()
  • getErrors()

It would be useful if the raw headers were accessible by the user in these scenarios.

Steps to Replicate

  1. Create a VM template in PVE
  2. SSH onto the node this template is on, and open the template config file at /etc/pve/qemu-server/<VMID>.conf
  3. Add the line lock: backup to the bottom of the file, to manually lock the template
  4. Try to clone the VM using the Proxmox API, you should get an error message in the response headers rather than the body

Solution

There are multiple ways to solve this, but one way could potentially be to add a new field to the Result class, which contains the contents of the raw headers. The headers can then be inspected by the user when they encounter an error, if they need to.

I believe the code would need to be added somewhere here: https://github.com/Corsinvest/cv4pve-api-php/blob/master/src/PveClientBase.php#L460


Happy to create a PR for this feature. Thanks for reading.

Originally created by @sydive on GitHub (Jul 26, 2024). Original GitHub issue: https://github.com/Corsinvest/cv4pve-api-php/issues/36 Hey there, thanks for the library, it's been great to use so far. ## Overview This is more of a feature request than bug, but it appears that the Proxmox API returns errors in HTTP headers, rather than the JSON response body in some cases. This happens in multiple endpoints, but one example can be seen in `/api2/json/nodes/{node}/qemu/{vmid}/clone` ([docs here](https://pve.proxmox.com/pve-docs/api-viewer/#/nodes/{node}/qemu/{vmid}/clone)). Here's what the headers looks like: ``` HTTP/1.1 500 VM is locked (backup) Cache-Control: max-age=0 Connection: close Date: Thu, 25 Jul 2024 23:24:26 GMT Pragma: no-cache Server: pve-api-daemon/3.0 Content-Length: 13 Content-Type: application/json;charset=UTF-8 Expires: Thu, 25 Jul 2024 23:24:26 GMT ``` Since this error is in the header rather than body, it's not present in the following methods for the `Result` class: * `getReasonPhrase()` * `getResponse()` * `getErrors()` It would be useful if the raw headers were accessible by the user in these scenarios. ## Steps to Replicate 1. Create a VM template in PVE 2. SSH onto the node this template is on, and open the template config file at `/etc/pve/qemu-server/<VMID>.conf` 3. Add the line `lock: backup` to the bottom of the file, to manually lock the template 4. Try to clone the VM using the Proxmox API, you should get an error message in the response headers rather than the body ## Solution There are multiple ways to solve this, but one way could potentially be to add a new field to the `Result` class, which contains the contents of the raw headers. The headers can then be inspected by the user when they encounter an error, if they need to. I believe the code would need to be added somewhere here: https://github.com/Corsinvest/cv4pve-api-php/blob/master/src/PveClientBase.php#L460 ----- Happy to create a PR for this feature. Thanks for reading.
kerem closed this issue 2026-02-26 17:32:10 +03:00
Author
Owner

@franklupo commented on GitHub (Jul 26, 2024):

If you want to create a PR.

best regards

<!-- gh-comment-id:2253171424 --> @franklupo commented on GitHub (Jul 26, 2024): If you want to create a PR. best regards
Author
Owner

@sydive commented on GitHub (Jul 29, 2024):

I've created a PR here: https://github.com/Corsinvest/cv4pve-api-php/pull/37

Could you please take a look when you have some time?

<!-- gh-comment-id:2254750169 --> @sydive commented on GitHub (Jul 29, 2024): I've created a PR here: https://github.com/Corsinvest/cv4pve-api-php/pull/37 Could you please take a look when you have some time?
Sign in to join this conversation.
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-php#27
No description provided.