[GH-ISSUE #114] [BUG] snap --dry-run non-zero return code #97

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

Originally created by @tlapik123 on GitHub (Feb 20, 2026).
Original GitHub issue: https://github.com/Corsinvest/cv4pve-autosnap/issues/114

What happened?

Hi!

When I run autosnap is with --dry-run in snap mode I get non-zero exit code. - When I run clean command it works as expected.

I suspect that the problem is here:

github.com/Corsinvest/cv4pve-autosnap@9fadfabd83/src/Corsinvest.ProxmoxVE.AutoSnap.Api/Application.cs (L378)

The clean command has false there, but maybe there is some deeper reason for true, that I'm not getting. (Its nice to have "fail by default" path tho.)

I hope this isn't just my wrong usage of script. 🙏

Expected behavior

Have zero exit code when everything goes OK or error message when not.

Command used

./cv4pve-autosnap --host=proxmox.example.com --api-token=xxx --vmid=xxx snap --dry-run --label=short --keep=2

Log output

dbug: Corsinvest.ProxmoxVE.Api.PveClientBase[0]
      Method: GET, Url: https://proxmox.example.com:8006/api2/json/version
trce: Corsinvest.ProxmoxVE.Api.PveClientBase[0]
      {
        "data": {
          "version": "7.2-11",
          "release": "7.2",
          "repoid": "b76d3178"
        }
      }
dbug: Corsinvest.ProxmoxVE.Api.PveClientBase[0]
      StatusCode: OK ReasonPhrase: OK IsSuccessStatusCode: True
dbug: Corsinvest.ProxmoxVE.Api.PveClientBase[0]
      Method: GET, Url: https://proxmox.example.com:8006/api2/json/version
trce: Corsinvest.ProxmoxVE.Api.PveClientBase[0]
      {
        "data": {
          "repoid": "b76d3178",
          "release": "7.2",
          "version": "7.2-11"
        }
      }
dbug: Corsinvest.ProxmoxVE.Api.PveClientBase[0]
      StatusCode: OK ReasonPhrase: OK IsSuccessStatusCode: True
ACTION Snap
PVE Version:      7.2-11
VMs:              297
Label:            short
Keep:             2
State:            False
Only running:     False
Timeout:          30 sec.
Timestamp format: yyMMddHHmmss
Max % Storage :   95%
dbug: Corsinvest.ProxmoxVE.Api.PveClientBase[0]
      Method: GET, Url: https://proxmox.example.com:8006/api2/json/cluster/resources?type=vm
trce: Corsinvest.ProxmoxVE.Api.PveClientBase[0]
      {
        "data": [ /* censored */ ]
      }
dbug: Corsinvest.ProxmoxVE.Api.PveClientBase[0]
      StatusCode: OK ReasonPhrase: OK IsSuccessStatusCode: True
dbug: Corsinvest.ProxmoxVE.Api.PveClientBase[0]
      Method: GET, Url: https://proxmox.example.com:8006/api2/json/cluster/resources?type=storage
trce: Corsinvest.ProxmoxVE.Api.PveClientBase[0]
      {
        "data": [ /* censored */ ]
      }
dbug: Corsinvest.ProxmoxVE.Api.PveClientBase[0]
      StatusCode: OK ReasonPhrase: OK IsSuccessStatusCode: True
      /* censored */
----- VM 297 qemu running -----
dbug: Corsinvest.ProxmoxVE.Api.PveClientBase[0]
      Method: GET, Url: https://proxmox.example.com:8006/api2/json/nodes/proxmox-node-censored/qemu/297/config
trce: Corsinvest.ProxmoxVE.Api.PveClientBase[0]
      {
        "data": { /* censored */ }
      }
dbug: Corsinvest.ProxmoxVE.Api.PveClientBase[0]
      StatusCode: OK ReasonPhrase: OK IsSuccessStatusCode: True
Create snapshot: autoshort260220174547
Total execution 00:00:00.1699101

cv4pve-autosnap Version

v1.20.0

Proxmox VE Version

7.2-11 and 8.4.14

Last working version

Did test v1.20 and 1.19 - both didn't work.

Operating System

Linux

Pull Request

  • I would like to do a Pull Request
Originally created by @tlapik123 on GitHub (Feb 20, 2026). Original GitHub issue: https://github.com/Corsinvest/cv4pve-autosnap/issues/114 ### What happened? Hi! When I run autosnap is with `--dry-run` in `snap` mode I get non-zero exit code. - When I run `clean` command it works as expected. I suspect that the problem is here: https://github.com/Corsinvest/cv4pve-autosnap/blob/9fadfabd8334fa5732e2bd18b1bf98319fbb4bb3/src/Corsinvest.ProxmoxVE.AutoSnap.Api/Application.cs#L378 The `clean` command has `false` there, but maybe there is some deeper reason for true, that I'm not getting. (Its nice to have "fail by default" path tho.) I hope this isn't just my wrong usage of script. 🙏 ### Expected behavior Have zero exit code when everything goes OK or error message when not. ### Command used ```bash ./cv4pve-autosnap --host=proxmox.example.com --api-token=xxx --vmid=xxx snap --dry-run --label=short --keep=2 ``` ### Log output ```shell dbug: Corsinvest.ProxmoxVE.Api.PveClientBase[0] Method: GET, Url: https://proxmox.example.com:8006/api2/json/version trce: Corsinvest.ProxmoxVE.Api.PveClientBase[0] { "data": { "version": "7.2-11", "release": "7.2", "repoid": "b76d3178" } } dbug: Corsinvest.ProxmoxVE.Api.PveClientBase[0] StatusCode: OK ReasonPhrase: OK IsSuccessStatusCode: True dbug: Corsinvest.ProxmoxVE.Api.PveClientBase[0] Method: GET, Url: https://proxmox.example.com:8006/api2/json/version trce: Corsinvest.ProxmoxVE.Api.PveClientBase[0] { "data": { "repoid": "b76d3178", "release": "7.2", "version": "7.2-11" } } dbug: Corsinvest.ProxmoxVE.Api.PveClientBase[0] StatusCode: OK ReasonPhrase: OK IsSuccessStatusCode: True ACTION Snap PVE Version: 7.2-11 VMs: 297 Label: short Keep: 2 State: False Only running: False Timeout: 30 sec. Timestamp format: yyMMddHHmmss Max % Storage : 95% dbug: Corsinvest.ProxmoxVE.Api.PveClientBase[0] Method: GET, Url: https://proxmox.example.com:8006/api2/json/cluster/resources?type=vm trce: Corsinvest.ProxmoxVE.Api.PveClientBase[0] { "data": [ /* censored */ ] } dbug: Corsinvest.ProxmoxVE.Api.PveClientBase[0] StatusCode: OK ReasonPhrase: OK IsSuccessStatusCode: True dbug: Corsinvest.ProxmoxVE.Api.PveClientBase[0] Method: GET, Url: https://proxmox.example.com:8006/api2/json/cluster/resources?type=storage trce: Corsinvest.ProxmoxVE.Api.PveClientBase[0] { "data": [ /* censored */ ] } dbug: Corsinvest.ProxmoxVE.Api.PveClientBase[0] StatusCode: OK ReasonPhrase: OK IsSuccessStatusCode: True /* censored */ ----- VM 297 qemu running ----- dbug: Corsinvest.ProxmoxVE.Api.PveClientBase[0] Method: GET, Url: https://proxmox.example.com:8006/api2/json/nodes/proxmox-node-censored/qemu/297/config trce: Corsinvest.ProxmoxVE.Api.PveClientBase[0] { "data": { /* censored */ } } dbug: Corsinvest.ProxmoxVE.Api.PveClientBase[0] StatusCode: OK ReasonPhrase: OK IsSuccessStatusCode: True Create snapshot: autoshort260220174547 Total execution 00:00:00.1699101 ``` ### cv4pve-autosnap Version v1.20.0 ### Proxmox VE Version 7.2-11 and 8.4.14 ### Last working version Did test v1.20 and 1.19 - both didn't work. ### Operating System Linux ### Pull Request - [x] I would like to do a Pull Request
kerem 2026-02-26 17:44:24 +03:00
Author
Owner

@franklupo commented on GitHub (Feb 20, 2026):

Thank you for reporting this issue and for the detailed log! 🙏

The bug has been fixed in v1.21.0:

  • inError was incorrectly initialized to true and never reset when --dry-run skipped the snapshot creation block
  • Changed to false as default (consistent with SnapshotsRemoveAsync) with explicit inError = true in the catch block

The fix is available in the v1.21.0 release.

<!-- gh-comment-id:3936318888 --> @franklupo commented on GitHub (Feb 20, 2026): Thank you for reporting this issue and for the detailed log! 🙏 The bug has been fixed in v1.21.0: - `inError` was incorrectly initialized to `true` and never reset when `--dry-run` skipped the snapshot creation block - Changed to `false` as default (consistent with `SnapshotsRemoveAsync`) with explicit `inError = true` in the `catch` block The fix is available in the [v1.21.0 release](https://github.com/Corsinvest/cv4pve-autosnap/releases/tag/v1.21.0).
Author
Owner

@tlapik123 commented on GitHub (Feb 21, 2026):

Thank you very much for such a quick fix! 💙

Sidenote - I actually like the "fail by default" approach, but I get why here its more trouble than worth 🚀

<!-- gh-comment-id:3937893311 --> @tlapik123 commented on GitHub (Feb 21, 2026): Thank you very much for such a quick fix! 💙 Sidenote - I actually like the "fail by default" approach, but I get why here its more trouble than worth 🚀
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-autosnap#97
No description provided.