Skip to content

fix: _list() filter matches falsy-but-valid field values - #26

Merged
atoomic merged 1 commit into
cpan-authors:masterfrom
Koan-Bot:koan.atoomic/fix-listable-falsy-filter
Sep 11, 2026
Merged

atoomic merged 1 commit into
cpan-authors:masterfrom
Koan-Bot:koan.atoomic/fix-listable-falsy-filter

Conversation

@Koan-Bot

@Koan-Bot Koan-Bot commented Apr 21, 2026 •

Copy link
Copy Markdown
Contributor

What

Fix _list() client-side filtering to correctly match entries with falsy field values (0, empty string).

Why

The filter logic used Perl truthiness ($candidate->{$filter} && ...) which silently excluded entries where the field held 0, "0", or "". In OpenStack, fields like OS-EXT-STS:power_state are 0 for stopped VMs — filtering by power_state=0 returned no results.

How

Replace truthiness check with defined() on lines 52 and 57 of Listable.pm. Only truly undef/missing fields are now excluded.

Testing

New t/listable-filter.t covers:

  • Filter by numeric zero value (power_state => 0)
  • Filter by empty string value
  • Regex filter on zero value
  • Filter by absent field still excludes correctly

All existing tests pass.

🤖 Generated with Claude Code


Quality Report

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

Code scan: clean

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

The filtering logic in Listable::_list() used a truthiness check
($candidate->{$filter} && ...) which silently rejected entries where
the filtered field held a legitimate falsy value like 0, "0", or
empty string. OpenStack responses include such values (e.g.,
OS-EXT-STS:power_state = 0 for stopped VMs).

Replace the truthiness check with defined() so that only truly
missing/undef fields are excluded from results.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@atoomic
atoomic marked this pull request as ready for review September 11, 2026 00:12
@atoomic
atoomic merged commit a50fa16 into cpan-authors:master Sep 11, 2026
19 of 22 checks passed
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