Skip to content

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

Merged
atoomic merged 1 commit into
cpan-authors:mainfrom
Koan-Bot:koan.atoomic/fix-image-from-name-consistency
Sep 11, 2026
Merged

atoomic merged 1 commit into
cpan-authors:mainfrom
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

@atoomic

atoomic commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

@Koan-Bot rebase

@atoomic
atoomic marked this pull request as ready for review September 11, 2026 00:13
…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 <[email protected]>
@Koan-Bot
Koan-Bot force-pushed the koan.atoomic/fix-image-from-name-consistency branch from 6058444 to ff306de Compare September 11, 2026 01:00
my @ids = map { $_->{id} // 'unknown' } @$images;
die "image_from_name: multiple images found for name '$name'"
. " (ids: " . join(', ', @ids) . ")."
. " Use image_from_uid to select a specific image";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a behavior change, but it makes sense to have a consistent and unique reply regarding the function name

@Koan-Bot

Copy link
Copy Markdown
Contributor Author

Rebase with conflict resolution

Branch koan.atoomic/fix-image-from-name-consistency was rebased onto main with automatic conflict resolution.

Stats

2 files changed, 89 insertions(+), 3 deletions(-)
Actions performed
  • Already-solved check: negative (confidence=high, reasoning=main's image_from_name still warns and returns the arrayref on duplicate names, so the core type-i)
  • Resolved merge conflicts (1 round(s))
  • Rebased koan.atoomic/fix-image-from-name-consistency onto upstream/main
  • Pre-push CI check: previous run #24454560262 failed
  • Pre-push CI fix: no changes needed or Claude found nothing to fix
  • Force-pushed koan.atoomic/fix-image-from-name-consistency to origin
  • Private review gate passed
  • CI check enqueued in ## CI (async)

CI status

CI will be checked asynchronously.


Automated by Skuggi

@atoomic
atoomic merged commit 80ce160 into cpan-authors:main Sep 11, 2026
19 checks passed
atoomic added a commit that referenced this pull request Sep 11, 2026
Covers the merge of #23.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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.

2 participants