Skip to content

fix(scenarios): guard delete/reset scripts against invalid JSON from proxmox_vm.list#47

Open
t0kubetsu wants to merge 1 commit into
mainfrom
fix/delete-reset-jq-guard
Open

fix(scenarios): guard delete/reset scripts against invalid JSON from proxmox_vm.list#47
t0kubetsu wants to merge 1 commit into
mainfrom
fix/delete-reset-jq-guard

Conversation

@t0kubetsu
Copy link
Copy Markdown

Summary

  • Captures proxmox_vm.list.to.jsons.sh output into a variable before processing in all delete and reset scripts
  • Validates the output with jq -e . and aborts with a clear error if it is not valid JSON
  • Reuses the captured output for both the stop and delete pipelines (one fewer API call per script)
  • Removes the misleading "non-fatal" comment in blank_scenario_2_subnets.delete_all.sh

Problem

All delete_all.sh, delete_vms_only.sh, and reset.setup.sh scripts piped proxmox_vm.list.to.jsons.sh directly into jq -c with no guard:

proxmox_vm.list.to.jsons.sh | jq -c | grep -E "..." | proxmox_vm.vm_id.stop_force.to.jsons.sh
proxmox_vm.list.to.jsons.sh | jq -c | grep -E "..." | proxmox_vm.vm_id.delete.to.jsons.sh

When the API returns an error string (stale token, Proxmox unreachable), jq emits a parse error and produces no output. The stop and delete commands receive no VM IDs — silently skipping all deletions while still exiting 0.

The blank_scenario_2_subnets.delete_all.sh even had a comment incorrectly calling this non-fatal. The comment described Ansible warning lines leaking into stdout, which are indeed harmless — but a full non-JSON error response from the API is not, and was being silently ignored.

Affected files

20 scripts across all 7 scenarios: blank_scenario_2/4/6_subnets, debug_scenario_a/b, demo_lab, _init_lab

Related

Closes #46
Same pattern fixed in range42-context.sh via range42/range42#110
Discovered during validation run for range42/range42#105

…proxmox_vm.list

Capture the output of proxmox_vm.list.to.jsons.sh into a variable,
validate it with jq -e before processing, and abort with a clear error
message if the output is not valid JSON.

Previously, any non-JSON output (e.g. an API error when the token is
stale or Proxmox is unreachable) caused jq to emit a parse error and
produce no output. The stop and delete commands then received no VM IDs,
silently skipping all deletions while still exiting 0. The subsequent
deploy would fail with HTTP 500 "config file already exists".

Also removes the misleading "non-fatal" comment in
blank_scenario_2_subnets.delete_all.sh that incorrectly described
this failure mode as harmless.

Affects all 20 delete_all/delete_vms_only/reset.setup scripts across
all scenarios: blank_scenario_2/4/6_subnets, debug_scenario_a/b,
demo_lab, _init_lab.

Fixes #46
@t0kubetsu t0kubetsu force-pushed the fix/delete-reset-jq-guard branch from a0cd04c to 45b4e71 Compare May 11, 2026 13:06
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

Successfully merging this pull request may close these issues.

bug: delete/reset scripts silently skip VM deletion on invalid JSON from proxmox_vm.list

1 participant