Skip to content

fix: image_from_name() dies on duplicate names instead of returning wrong type - #23

Draft
Koan-Bot wants to merge 1 commit into
atoomic:masterfrom
Koan-Bot:koan.atoomic/fix-image-from-name-consistency
Draft

fix: image_from_name() dies on duplicate names instead of returning wrong type#23
Koan-Bot wants to merge 1 commit into
atoomic:masterfrom
Koan-Bot:koan.atoomic/fix-image-from-name-consistency

Conversation

@Koan-Bot

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

Copy link
Copy Markdown
Contributor

What

image_from_name() now dies with a descriptive error when multiple images share the same name, instead of returning an incompatible type.

Why

When multiple Glance images shared a name, image_from_name() returned an arrayref instead of a hashref. Callers like create_vm() do $image->{id} — on an arrayref, this silently evaluates to undef, causing a confusing "Failed to create server" error much later in the flow. The root cause was invisible.

How

  • Die with a message that lists the duplicate image IDs and points the user to image_from_uid
  • Replace bare die statements in Images.pm with descriptive messages
  • Fix typo in images() error message (missing "or")

Testing

  • Added 6 new tests: duplicate image names (die + message check), missing uid/name params, no-results case, images() not exposed via AUTOLOAD
  • Full test suite passes (all existing + new tests)

🤖 Generated with Claude Code


Quality Report

Changes: 2 files changed, 92 insertions(+), 6 deletions(-)

Code scan: clean

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

…rong type

image_from_name() returned an arrayref when multiple images shared the
same name, but callers (like create_vm) expected a hashref. This caused
$image->{id} to silently evaluate to undef, leading to confusing API
errors downstream.

Now dies with a descriptive message listing the duplicate IDs and
suggesting image_from_uid as the workaround.

Also fixes bare die statements in Images.pm with descriptive messages
and corrects the images() error message (missing "or").

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