Skip to content

fix: create_vm robustness and cleanup - #16

Draft
Koan-Bot wants to merge 2 commits into
atoomic:masterfrom
Koan-Bot:koan.atoomic/fix-create-vm-bugs
Draft

fix: create_vm robustness and cleanup#16
Koan-Bot wants to merge 2 commits into
atoomic:masterfrom
Koan-Bot:koan.atoomic/fix-create-vm-bugs

Conversation

@Koan-Bot

@Koan-Bot Koan-Bot commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

What

Fix three bugs in create_vm() and remove dead WhiteSource config.

Why

  • Image null-check missing: If image lookup fails (neither UUID nor name match), $image->{id} crashes with cryptic "Can't use undef as HASH ref" instead of a helpful error message.
  • Redundant condition: $server_status->{status} was checked twice in the active-status loop — copy-paste artifact.
  • Wrong test fixture: json_imageid() used Compute-style {image: {...}} wrapping, but image_from_uid hits Glance v2 API which returns a flat hash. This meant $image->{id} was silently undef in tests (masked because the POST mock ignores parameter values).

How

  • Added null-check after image lookup matching the pattern used by look_by_id_or_name() for other resources
  • Removed the duplicate condition line
  • Fixed test fixture to match actual Glance v2 API response format
  • Added test for image-not-found error path
  • Removed abandoned .whitesource config (separate commit)

Testing

Full test suite passes (prove -lv t/ — 27 tests across 6 files).

🤖 Generated with Claude Code


Quality Report

Changes: 3 files changed, 39 insertions(+), 44 deletions(-)

Code scan: clean

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

Koan-Bot and others added 2 commits April 9, 2026 06:06
…st fixture

Three bugs fixed in create_vm():

1. Missing null-check after image lookup — if neither image_from_uid nor
   image_from_name finds a match, $image->{id} would crash with a cryptic
   "Can't use undef as HASH ref" error. Now dies with a descriptive message.

2. Redundant condition — $server_status->{status} was checked twice in the
   active-status condition (copy-paste artifact).

3. Wrong test fixture format — json_imageid() used Compute-style {image: {...}}
   wrapping, but image_from_uid hits Glance v2 API which returns a flat hash.
   This meant $image->{id} was silently undef in tests (masked because the
   POST mock doesn't validate imageRef). Fixed to match actual Glance v2 format.

Also adds a test for the image-not-found error path and fixes a typo in comment.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
WhiteSource dependency scanning config has been abandoned — no active
integration exists. Modern projects use GitHub's native Dependabot or
similar alternatives.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant